开发者

postback for one row in a gridview

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜