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.

2 thoughts on “ASP .NET GridView Access to Data In Code

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

    Like

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

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close