开发者

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; 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]开发者_如何学Go.FindControl("Label1");
    CU.Username = LBL.Text;
    if (CU.BasiclyExists())
    {
        LblRseult.Visible = true;
        LblRseult.Text = "This user already exists";
    }     
}


You can access control inside TemplateField this way:

Label lbl = GridView1.Rows[e.RowIndex].FindControl("Label1") as Label;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜