Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
Hello Friends

I have a query related grid view in asp.net. My query is that I want to get selected row index on check box click of grid view in asp.net. I want to use this selected row index in my code.

Please Provide me the solution for this.
Posted
Updated 19-Sep-11 18:58pm
v3

use link button or any button but you have to pass command argument like written below

C#
<asp:linkbutton id="LinkButton1" runat="server" causesvalidation="False" commandname="Edit" commandargument="<%# Container.DataItemIndex %>" xmlns:asp="#unknown"> </asp:linkbutton> 

after that you can get Rowindex from code behind like this

C#
int RowIndex = Convert.ToInt32(e.CommandArgument.ToString());
 
Share this answer
 
v2
 
Share this answer
 
if you are in row databound event you can get like this


e.Row.RowIndex
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900