Be extremely clear. The button click event occurs after the Page_Load event, which means that filtering does not apply to the first postback. It has been updated in the second postback, and you see the filtering. The simplest change to make your code work is to move all the code to your Page_Load event in OnPreRender so that a reboot occurs after the button click event.
However, a cleaner solution would probably move it to the LoadData function and call it on the Load page when it is not a postback, and also call it on the button click event after updating the filters. This will prevent any postback cycles that do not require data reloading to be called into the database:
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadData() } } private void LoadData() { labDownloadList.Text = null;
The final piece of quick advice for the aspiring ASP.Net developer is to thoroughly examine the page life cycle. Knowing the sequence of events on a page is important. Good luck.
Jackcorn
source share