Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am creating a webpage with 3 actions for users:

1. Id is selected by user from drop down list. The related data is shown in text boxes below.

2. User makes changes in the text boxes.

3. User clicks Save button to update the changes in database.


Problem is when the user clicks Save button, the Page load event runs before the button click event reloading the data based on dropdownlist selection and in process removing all changed elements from text boxes.

Pls guide. Thanks
Posted

1 solution

Quote:
Page load event runs before the button click event

As designed, read ASP.NET Application and Page Life Cycle[^]
And ASP.NET Page Life Cycle Overview [^]

Quote:
the button click event reloading the data based on dropdownlist selection and in process removing all changed elements from text boxes.

Don't bind data on postback[^]

in page load event, do as below

C#
if(!IsPostBack)
{
  // here bind the data to your controls like gridviews drop down lists

}
 
Share this answer
 
v5
Comments
atul sharma 5126 25-May-14 1:45am    
Thanks. It worked partially in reverse way.
The data started saving when binding is done if NOT POSTBACK. But now the data is not displayed on selected index changed event as it also comes under postback.
Any suggestions

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900