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.

Était-ce utile?

La 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

    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top