2016-09-07 25 views

回答

0

試試這個onRowEditing事件

GridViewRow row = MyGrid.Rows[e.RowIndex]; 
Label MyLabel = (Label)row.FindControl("MyLabel"); 

lableText值指定到你想要的文本框。

更新1:

DataRow row = ((DataRowView)e.Row.DataItem).Row; 
Label Mylabel = (Label)e.Row.FindControl("MyLabel"); 

MyLable是您定義爲您的GridView .aspx頁面中

+0

未將對象引用設置爲對象的實例。錯誤發生 – svs

0

上爲行編輯和更新,你可以使用這個控件ID ...

protected void grdemployee_RowUpdating(object sender, GridViewUpdateEventArgs e) 
{ 
     int id = Int32.Parse(grdemployee.DataKeys[e.RowIndex].Value.ToString()); 
     TextBox txtname = (TextBox)grdemployee.Rows[e.RowIndex].FindControl("txtname"); 
     grdemployee.EditIndex = -1; BindGridview(); 
} 
相關問題