如何找到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;

posted @ 2012-02-07 14:20  志誠  阅读(423)  评论(0编辑  收藏  举报