且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-10-07 14:55:28

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



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 [ ^ ]