如何找到GridView里的控件,建立GridViewRow对象

如要找到一个lable控件

在RowCommand事件下:

GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).Parent.Parent;

(如果e.CommandName的命令源不是TemplateField列,如ButtonField,还可直接使用Convert.ToInt32(e.CommandArgument.ToString())来得到行过索引)

在可得到行索引index时

GridViewRow gvr = gvData.Rows[index];

Label num = gvr.FindControl("lblP_NUM") as Label;

原文地址:https://www.cnblogs.com/pfcan66/p/2341444.html