Delete linkbutton not firing inside a gridview inside an update panel
Looked to various posts on here but couldn't find one quite like it, I know this is going to be something small but I just can't figure it out.
I am using a gridview inside an update panel. The gridview is using the auto generated delete column converted into a templatefield column. Here is the code:
<asp:GridView ID="gvFiles" runat="server" AutoGenerateColumns="False"
CellPadding="4"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<Columns>
<asp:TemplateField HeaderText="Files" HeaderStyle-HorizontalAlign="Left">
<ItemStyle Width="210px" />
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#Eval("Id", "~/Download.aspx?id={0}")%>'><%#Eval("LinkName")%></asp:HyperLink>,<br />
Last Modified: <%#Me.cutDate(Eval("DateModified"))%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" HeaderText="Team">
<ItemStyle Width="150px" />
<HeaderStyle HorizontalAlign="Left"></HeaderStyle>
<ItemTemplate>
<%#Me.GetTeamName(Eval("TeamId"))%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this post?');"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
I've got this exact same code working fine when it's not inside the update panel. What do I need to do to get this to work?
Edit: Forgot to mention, my update panel settings are all defa开发者_JAVA技巧ult. Also what happens is you click delete, the confirmation message pops up, you click Yes, and then nothing happens.
I was having the same problem with the edit button only, all the others worked fine which I thought was odd. So I added an onclick event to the edit button that rebound the gridview and it worked. With breakpoints I saw that the gridview set the editIndex correctly on the first click but didn't change to the editItem templates until the second click. Hope this gives you some ideas.
I think you will have to add this
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnFindOrder" EventName="Click" />
</Triggers>
精彩评论