Juvil
Juvil

Reputation: 490

Postback a linkbutton in a grid that's under an UpdatePanel

as my title says...

How do you make a LinkButton fire a POSTBACK (not ASYNCPOSTBACK) which is inside a GridView and is under an UpdatePanel?

My Scenario is this,

I have a grid. say table A, which populates a Linkbuttons with link to do Server.Transfer calls from Page1 to Page2.

I have a good reason why i am using a Server.Transfer because of previous page referencing methods and Response.Redirect doesnt fit at all.

normally it would work if i add the grid as a Postback trigger in the UpdatePanel like so

<Triggers><asp:PostBackTrigger ControlID="gvitem" /></Triggers>

but since I have another control inside the grid that needs to be do an AsyncPostback, that would not work also,

all that's lacking is have this line of code, do postback.

<asp:TemplateField HeaderText="Description" SortExpression="ShortDesc">
     <ItemTemplate>
           <asp:LinkButton ID="btndesc" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ShortDesc")%>' CommandName="Edit" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "Key") %>' />
     </ItemTemplate>
</asp:TemplateField>

anyone have an idea?

Upvotes: 0

Views: 1776

Answers (1)

rick schott
rick schott

Reputation: 20617

Find btndesc on grid.ItemDataBound and register it as a PostBackTrigger.

Upvotes: 2

Related Questions