Hello,
I have this code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:Accordion ID="Accordion1" runat="server"
SuppressHeaderPostbacks="true"
SelectedIndex="0"
HeaderCssClass="header"
HeaderSelectedCssClass="headerSelected"
ContentCssClass="contentAcc"
AutoSize="None"
FadeTransitions="true"
TransitionDuration="100"><HeaderTemplate><%--<asp:Label ID="lbHeaderID" runat="server" Text='<%# Eval("InspectionID")%>'></asp:Label>--%><table style="width:100%"><tr style="width:100%; background-color:lightgray"><td style="width:9.9%"> <asp:LinkButton ID="lbInspectionDate" Text='<%# Eval("SurveyDate")%>' runat="server"></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbAuditors" runat="server" Text='<%# Eval("AudLastName")%>'></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbVP" runat="server" Text='<%# Eval("VPLastName")%>'></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbManager" runat="server" Text='<%# Eval("ManLastName")%>'></asp:LinkButton> </td><td style="width:30.5%"> <asp:LinkButton ID="lbOrg" runat="server" Text='<%# Eval("Organization")%>'></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbFac" runat="server" Text='<%# Eval("Facility")%>'></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbDeficiency" runat="server" Text='<%# Eval("Deficiencies")%>'></asp:LinkButton> </td><td style="width:9.9%"> <asp:LinkButton ID="lbCompleted" runat="server" Text='<%# Eval("Active")%>'></asp:LinkButton> </td></tr></table></HeaderTemplate><ContentTemplate><asp:HiddenField ID="hfInspectionID" runat="server" value='<%# Eval("InspectionID")%>' /><table style="width:100%"><tr style="width:100%"><td><asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/delete2.jpg" /><br /><asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/250_PPT8800.jpg" /></td><td><asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False"><Columns><asp:BoundField DataField="Severity" HeaderText="Class" SortExpression="DeficiencyID" /><asp:BoundField DataField="Deficiency" HeaderText="Deficiency" SortExpression="ViolationID" /><asp:BoundField DataField="Completed" HeaderText="Completed" SortExpression="DeficiencyID" /><asp:BoundField DataField="DeficiencyID" HeaderText="Completed?" SortExpression="DeficiencyID" /><asp:ButtonField CommandName="Details_Click" HeaderText="Details" Text="Click Here" /><asp:TemplateField ><ItemTemplate> <asp:ImageButton ID="btnViewDetails" runat="server" OnClick="btnViewDetails_Click" ImageUrl='<%#"~/images/250_PPT8800.jpg"%>' /> </ItemTemplate><ItemStyle HorizontalAlign="Right" /></asp:TemplateField></Columns></asp:GridView></td></tr></table></ContentTemplate></asp:Accordion></ContentTemplate></asp:UpdatePanel>
As you can see I have 2 buttons one is an image button the other is a gridview ButtonField button. In the code behind I have this code:
Protected Sub btnViewDetails_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim ss As String
Dim GridView1 As GridView = CType(Me.Accordion1.FindControl("GridView1"), GridView)
Dim btnDetails As ImageButton = TryCast(sender, ImageButton)
Dim row As GridViewRow = DirectCast(btnDetails.NamingContainer, GridViewRow)
ss = row.Cells(3).Text
End SubThis works great when I run the code and click on the Image Button inside the grid the code behind fires and does what it is suppose to do.
My question is how do I make code behind that will capture the other button(gridview ButtonField button) click event?
Also can I put a button in the template field? and if so how to I make the code behind capture that click event?
Thank you