ASP .NET GridView Access to Data In Code

There are situations where you want to gain access to the GridView’s DataSet to display extra information outside of the GridView. I found the following code to work the best for me. You can get the information from the DataSource of a GridView by doing the following:

DataView dv = (DataView)sdsDataSource.Select(DataSourceSelectArguments.Empty);
if (dv != null)
{
try
{
strName = (String)dv.Table.Rows[0]["Name"];
}
catch { strName = “N/A”; }
}

You should be able to access whatever information you need from the DataView.

No related posts.

Posted in Programming. Tagged with , , .

3 Responses

Comments RSS Feed.

  1. Programmers heavily use the asp.net gridview control. Adding some effects to the gridview will change the appearance so that user interactivity increases

  2. I definitely love reading your insight and learning from your blogsite. Thank you for the interesting and informative article. – Diego

  3. A very interesting article. I intend to pay more visits to your blog again soon.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.

Powered by WP Hashcash