6
Reply

How to get imagebuttonId in a gridview using jquery

Resmi Satish

Resmi Satish

Jul 4 2013 6:04 AM
3.4k
I am having an image button which has been placed inside a gridview.


Please find below my grid view :

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server">
    <asp:UpdatePanel runat="server" ID="UP">
<asp:GridView ID="ExpensesGridView" runat="server" AutoGenerateColumns="False"
                                        BorderColor="#004B9D" BorderStyle="Solid" BorderWidth="1px"
                                        CellPadding="4" ShowFooter="True"
                                        DataKeyNames="TimesheetId" Width="700px"
                                                                               onsorting="ExpensesGridView_Sorting" CssClass="Gvplacement">
 <asp:TemplateField HeaderText="Select for Approval" ItemStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="chkApprove" runat="server" />
                                                </ItemTemplate>
                                                <FooterTemplate>
                                                    Approve:</FooterTemplate>
                                                <FooterStyle HorizontalAlign="Center" />
                                                <ItemStyle HorizontalAlign="Center" />
                                            </asp:TemplateField>

  <ItemStyle HorizontalAlign="Center" />
                                                <FooterTemplate>
                                                    <asp:ImageButton ID="btnApprove"   runat="server" ToolTip="Click to approve selected expenses"
                                                        ImageUrl="~/App_Themes/Default/Images/buttons/icon_16x16_tick.gif" AlternateText="Approve"
                                                         CommandName="Approve" />
                                                </FooterTemplate>
                                                <FooterStyle HorizontalAlign="Center" />
                                            </asp:TemplateField>

</GridView >
      </ContentTemplate>
    </asp:UpdatePanel>

As I am new to jquery,I am not able to get the buttonId.

I have to create a  jquery function which will be called when we click the image button.

Purpose of the function:
Check if any check box is selected and if so , an alert message has to be displayed.


Answers (6)