开发者

postback for one row in a gridview

开发者 https://www.devze.com 2023-04-09 14:29 出处:网络
I put the gridview inside an UpdatePanel. the gridview contains numb开发者_StackOverflow社区er of columns:

I put the gridview inside an UpdatePanel. the gridview contains numb开发者_StackOverflow社区er of columns:

<UpdatePanel>
<GridView>
<asp:TemplateField HeaderText="View"> // column1
<asp:TemplateField HeaderText="View"> // column2
<asp:TemplateField HeaderText="View"> // column3
<GridView>
</UpdatePanel>

At the moment, If I click on the buttons of the 3 columns, they are AsyncPostBackTriggers. Would it be possible to make one the of the columns, for example: columm1 with a button that is PostbackTrigger?

Thanks in advance.


You can utilize a ScriptManager for registering button as postback control. Place the code below into Page_Load method after gridView binding instructions:

var scriptManager = ScriptManager.GetCurrent(this); 
foreach (GridViewRow row in GridView1.Rows)
{
    var syncPostBackButton = row.FindControl("ButtonID") as Button;
    if(syncPostBackButton != null)
    {
        scriptManager.RegisterPostBackControl(syncPostBackButton);
    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号