如何在Asp.Net的gridview中获取选定的行索引

问题描述:

你好朋友



我在asp.net中有一个与查询相关的网格视图。我的查询是,我希望在复选框中选择行索引点击asp.net中的网格视图。我想在我的代码中使用这个选定的行索引。



请为我提供解决方案。

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.

使用链接按钮或任何按钮,但你必须传递如下所示的命令参数



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

<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




int RowIndex = Convert.ToInt32(e.CommandArgument.ToString());


使用ASP.net,C#在GridView中选择行值[ ^ ]
selected row value in GridView using ASP.net, C#[^]


http://msdn.microsoft.com/en-us/library /system.web.ui.webcontrols.gridview.selectedrow.aspx [ ^ ]