Skip to content


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. Page.FindControl() Returning Null Issues and Solutions Within Another Control Alright, I'm going to have a lot of blog posts over the next few days going over my wonderful expereinces learning how to create advanced server controls, and just how hard it is to find good information on the subject. But the problem I ran into today was having Page.FindControl()...
  2. ASP .NET 2.0, GridViews, HyperLinkField, and JavaScript I've found some interesting notes on ASP .NET's GridView, it's limitations and work arounds. For work I was looking for a way to execute JavaScript from clicking a link on a GridView Cell. An example would be to having a list of transactions and wanting to click a link to...
  3. MySQL - Does Table Exist w/o Throwing Errors There are times where you would like to know if a table exists before executing an query. Most solutions require having MySQL throw an error saying "table does not exist," but I prefer a cleaner way. I found on this forum post a clean way to do it: PLAIN TEXT...
  4. ASP .NET & System.Threading.ThreadAbortException Error While doing some work today I started to run into a ThreadAbortException error. While debugging it spit back this error: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. I was really confused because everything seemed to be...
  5. ASP .NET, LINQ, GridViews, and GUID Errors I found a simple problem today. Here is the deal, there were several times where I had to base a LinqDataSource off a Guid that I would set in the Page_Load(). I created an<asp:HiddenField /> to hold the value so all my DataSources could pull it from the control. The...

Posted in Programming. Tagged with , , .

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.

Powered by WP Hashcash