我对Gridview的这个问题感到沮丧。
当位于页脚行中的链接按钮被点击时,我希望在gridview的RowCommand事件中获取行索引。
但我总是得到-1作为index
的值。
Control ctl = e.CommandSource as Control;
GridViewRow CurrentRow = ctl.NamingContainer as GridViewRow;
int index = CurrentRow.RowIndex;
如何解决这个问题?
LinkButton
添加OnClick
事件,并使用((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex
查找索引? - BharadwajCommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
并通过e.CommandArgument
找到索引。 - Bharadwaj