GridView and DataBinding (ADO.NET/ASP.NET)

Posted on 2008-11-08
Last Modified: 2013-12-17
How do I access the entire dataset/datatable in a gridview?  I am using data binding just a SqlDataSource (SqlDataSource1) configured to execute a stored proc passing some values from controls on a page.  The GridView control has it's DataSourceID set to SqlDataSource1.  I know how to use the DataSource property when manually writing the code, however I am modifying an exisiting application so I have some limitations without refactoring a ton of code.

On the click event of a button I need to access the data in the current grid (I am trying to avoid running the query again if at all possible).

Make sense?  Any thoughts?


Question by:eferron
    LVL 8

    Accepted Solution

    I think you will have to use the DataBinding or DataBound of the Grid Control, You will have to store the DataSet in a variable during that event, so that you can later have access to it.

    or probably the SQLDataSource DataBound event.
    LVL 6

    Expert Comment

    You can access data in the gridview by using
    Hope this helps

    Author Comment

    I have to have paging enabledso the grid does not have all of the data in only the current page.  I think I have determined that I will need to reexecute the query.

    Author Closing Comment

    Not really what I was looking for but it is close enough

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now