当在现场使用按需参数如何获得GridView控件的rowIndex [英] How to get rowindex in GridView when OnCommand argument used in the field
本文介绍了当在现场使用按需参数如何获得GridView控件的rowIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:LinkButton ID="lblViewDetail" runat="server" style="text-decoration:underline;" OnCommand="ViewSummary" CommandArgument='<%#Eval("ShowlinkDetail") %>' Text='View Detail' />
我有一个Menthod在cs文件,并在数据字段这个方法名字叫
I have one Menthod in .cs file and this method name call in the datafield
OnCommand="ViewSummary"
private void ViewSummary()
{
//code
}
当我在网格视图中点击拉布勒控制,然后我想要得到的帮助Rowindex.Please
when I click in the grid view on the lable control then I want to get the Rowindex.Please help.
推荐答案
在按需作为您的LinkButton会是这样的。
The OnCommand for your linkbutton would be something like this
protected void lnk_Command(object sender, CommandEventArgs e)
{
// The Namingcontainer would be Gridrow
// You can get the rowindex in this fashion
((sender as LinkButton).NamingContainer as GridViewRow).RowIndex
}
这篇关于当在现场使用按需参数如何获得GridView控件的rowIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文