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.

Related Posts

  1. Data Backups – There Are No Excuses Today I just had the terrible experience of having a database lose data, need to restore, only to not have a recent backup. If you haven’t had this experience before, please, take this serious. My wife was home for lunch as it happened, and she watched as the blood drained...

Posted in Programming. Tagged with , , .

2 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

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.

Powered by WP Hashcash