ASP.Net search button example to load GridView

asp.netbindingeventsgridview

Using ASP.Net 2.0

I need an example of how to load a GridView after clicking a button on the page.

I am unable to get the events right – with the PostBack in the PageLoad, seems it's not getting it right. I have three textboxes whose contents are passed to a query which is executed and a datatable is returned. But how and in which order?

Thansk,
Bob

Best Solution

Can you add the code that you are using so we can see what mistakes you may be making. Basically, your steps should look like this:

  1. Add event handler to button to call a method
  2. Within method, retrieve data from database into a datatable
  3. Set the gridview.datasource to the new datatable
  4. run gridview.databind to bind the data to the grid
Related Question