Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Row Index on Asp.net Rowcommand event

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.

like image 387
Shahin Avatar asked Jun 28 '11 07:06

Shahin


People also ask

How to get row index in GridView RowCommand event?

You can get the row index like this: GridViewRow row = (GridViewRow)(((Button)e. CommandSource).

How do I get GridView data in RowCommand event?

You can get the data on gridview_RowCommand event by placing below code: Int32 HistoryId = Convert. ToInt32(e. Row.


1 Answers

this is answer for your question.

GridViewRow gvr = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;  int RowIndex = gvr.RowIndex;  
like image 134
rahularyansharma Avatar answered Oct 14 '22 15:10

rahularyansharma