문제

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.

도움이 되었습니까?

해결책

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

    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top