简体   繁体   中英

ASP.NET gridview control rowCreated function after button click

I am wondering how can I control the execution order of server-side functions(asp.net and C#) for a post_back request?

For example: I have two buttons on my webpage, and click on any of them will trigger a post_back request. The post back will update a gridview in an AJAXUpdatePanel. I found that if I click button1, the functions execution order is: button1_onclick(); gridview1_rowCreated();

However, if I click button 2, the order is: gridview1_rowCreated(); button2_onClick();

Is there anyway to make the order consistent? Any comment is truly appreciated.

Try to Bind the grid on PreRender Event of the Page or Do the Task on the Button Clicked event and make sure you have first time binding done using an

if(!IsPostBack) 
{
 Code Binding Grid.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM