Accessing SQL data within Visual Web Developer 2010 to use as string

49 Views Asked by At

I've been struggling for abit trying to find away get the SQL data which I have obtained using 'GridView' and a 'SQLDATASOURCE' to output things like 'total rows' 'total of column A' into a label or to be used somewhere else.

Not sure what the code language is to link between the 'on demand' SQL query that triggers when the page is loaded and the code needed to access that 'on demand' information. I've tried searching here but I dont know the correct terminology to search correctly.

Regards Jamie

1

There are 1 best solutions below

0
On

If you want a label to output the number of rows in your gridview just assign the label.text to the number of rows.

 int count = gridview.Rows.Count;
 Label.text = count.ToString

or

 Label.text = gridview.Rows.Count.ToString;

You may have to play around with the gridview.Rows if you want to grab a specific column