[英]find control in grid view
I had code to find label in gridview and I checked on it,s label text and it gives me the index not text and this error apear object refrence not set to ..... so I wnat to give CU.Username = LBL.Text; 我有代码在gridview中找到标签,然后检查了标签文本,它给了我索引而不是文本,并且此错误出现对象的引用未设置为.....所以我要赋予CU.Username = LBL。文本; text no index of control code
文本无控制代码索引
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
LblRseult.Visible = true;
LblRseult.Text = "Successfully Process";
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
cUser CU = new cUser(this);
LBL = (Label)GridView1.Rows[e.RowIndex].Cells[1].FindControl("Label1");
CU.Username = LBL.Text;
if (CU.BasiclyExists())
{
LblRseult.Visible = true;
LblRseult.Text = "This user already exists";
}
}
您可以通过以下方式访问TemplateField中的控件:
Label lbl = GridView1.Rows[e.RowIndex].FindControl("Label1") as Label;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.