This not directly possible in ASP.NET. Following article discusses a workaround to get the current row in GridView RowCommand event.
http://ranafaisal.wordpress.com/2008/03/31/how-to-get-the-current-row-in-gridview-row-command-event/
The inline code for gridview displayed below.
Make sure you are handling the
http://ranafaisal.wordpress.com/2008/03/31/how-to-get-the-current-row-in-gridview-row-command-event/
The inline code for gridview displayed below.
<asp:GridView ID="grdTrackedItems" runat="server" AutoGenerateColumns="False" Width="330px"
BorderStyle="None" OnRowEditing="EditRecord" OnRowCommand="RowCommand">
<Columns>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblItem" runat="server" Text='<%# Eval("Item") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" ImageUrl="~/Resources/Images/Delete.png"
Height="12" Width="12" ToolTip="Delete" CommandName="Delete" />
</ItemTemplate>
<ItemStyle Width="22px" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Resources/Images/Edit.png"
Height="12" Width="12" ToolTip="Edit" />
</ItemTemplate>
<ItemStyle Width="22px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
Make sure you are handling the
OnRowEditing event(keep it blank)
protected void EditRecord(object sender, GridViewEditEventArgs e)
{
}
Cheers,
Happing coding
Samtha