.net – ASP.NET – Refreshing GridView Data on Page After Button Click

asp.netgridviewnetsoap

I've been working with C# and .NET for quite some time now, but am currently working on my first ever web application with ASP.NET. It took me quite some time playing around to realize that the Page_Load function was getting called before my button event handler, though, at this point I've got the application working properly around this behavior. However, the issue I'm having is this:

I have a GridView control that is bound to a SortedList in my application. The button click event handler saves data in a form to the database (actually, saves data via a SOAP service), then updates the list that the GridView is bound to in order to reflect the most up-to-date data (again, updates the list from the SOAP service). However, because the page refreshes before my button click event handler fires, the data doesn't actually appear updated on the page. What is the proper way to handle a situation like this? How can I get the data on the page to be refreshed, or at least up-to-date, after the button handler saves data even though the page has already refreshed? I've been struggling with this for quite awhile now, so any code example or links that'll help explain this would be much appreciated.

Thanks in advance!

Best Answer

try inside Page_Load

if (!IsPostBack)
 {
  //Bind your Grid
 }