Question

I have a form. On load it gets filled by Page_Load method with data. Now if user changes data and clicks the submit button the page refreshes reloads the original data and then onClick metod of the button gets called. Now it loads wrong (original) data from form not the data user put in.

How do avoid this ? Thanks.

Was it helpful?

Solution

In the Page_Load you need to wrap the data loading code in if (!IsPostBack){} like below:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
       //Your code to load data

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top