1
Reply

How to find Grid view row index value using command argument on button click

Bhupendra Singh

Bhupendra Singh

Oct 4 2012 11:39 AM
9.3k

<asp:TemplateField HeaderText="DELETE" HeaderStyle-CssClass="sfDelete">
                        <ItemTemplate>
  <asp:ImageButton ID="imbDelete" runat="server" CausesValidation="False" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
                                CommandName="Delete"   ToolTip="Delete the enquiry" />
</ItemTemplate>
                                </asp:TemplateField>


Fire Event of grid view row Command..
-------------------------------------------------------------------------------------------------------

protected void gdvRecord_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        
        if (e.CommandName == "EDIT")
        {
            int RowNum = int.Parse(e.CommandArgument.ToString());
}

}

Answers (1)