I have an asp.net GridView:
<asp:TemplateField HeaderText="View Faktor" ShowHeader="False" Visible="True"> <ItemTemplate> <asp:ImageButton ID="imgBtn1" CssClass="SelectRow" runat="server" CausesValidation="false" CommandArgument='<%#(eval("mprID")) %>' CommandName="ViewFactors" ImageUrl="~/tadarokat/Images/factor.png" Text="" /> </ItemTemplate> </asp:TemplateField>
How Can I get rowIndex
on row command event?
I want to highlight (select
) target row when RowCommand
fires.
You can get the row index like this: GridViewRow row = (GridViewRow)(((Button)e. CommandSource).
You can get the data on gridview_RowCommand event by placing below code: Int32 HistoryId = Convert. ToInt32(e. Row.
this is answer for your question.
GridViewRow gvr = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer; int RowIndex = gvr.RowIndex;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With