Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:GridView ID="MyGridView" runat="server" OnRowCommand="MyGirdView_OnRowCommand">
- <Columns>
- <asp:TemplateField>
- <ItemTemplate>
- <asp:LinkButton
- id="MyLinkButton"
- runat="server"
- CommandName="MyCommand"
- />
- </ItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
- protected void MyGirdView_OnRowCommand(object sender, GridViewCommandEventArgs e)
- {
- //need to access row index here....
- }
- LinkButton lb = (LinkButton) ((GridViewCommandEventArgs)e.CommandSource);
- LinkButton lb = e.CommandSource as LinkButton;
- GridViewRow gvr = lb.Parent.Parent as GridViewRow;
- int gvr = gvr.RowIndex;
- LinkButton lb = (LinkButton) ((GridViewCommandEventArgs)e.CommandSource);
- GridViewRow gr = (GridViewRow) lb.Parent.Parent;
- var id = gr.RowIndex;
- var id = ((GridViewRow)((LinkButton)((GridViewCommandEventArgs)e).CommandSource).Parent.Parent).RowIndex;
Add Comment
Please, Sign In to add comment