2010-07-26 78 views
0

我有代碼在gridview中查找標籤,我檢查了它,s標籤文本,它給了我索引不是文本,並且此錯誤apear對象引用未設置爲.....所以我wnat給CU.Username = LBL.Text;文本沒有控制 代碼索引在網格視圖中找到控件

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"; 
    }  
} 
+0

什麼是您的實際問題 - 我(我想很多人)不能從您的(原)告訴文本? – Tobiasopdenbrouw 2010-07-26 10:04:54

回答

5

你可以在裏面模板列訪問控制是這樣的:

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