olidev
olidev

Reputation: 20624

postback for one row in a gridview

I put the gridview inside an UpdatePanel. the gridview contains number 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.

Upvotes: 1

Views: 271

Answers (1)

IUnknown
IUnknown

Reputation: 22448

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);
    }

}

Upvotes: 1

Related Questions