GridView模板列有一TextBox,TextBox的AutoPostBack属性为True,在TextChanged事件中可通过如下代码获取当前行某列的值:
要注意的是当前行中的控件只能有一个控件名为lblCoId。
- TextBox t = (TextBox)sender;
- GridViewRow drv = (GridViewRow)t.NamingContainer;
- int rowIndex = drv.RowIndex;
- string coid = ((Label)gdvList.Rows[drv.RowIndex].FindControl("lblCoId")).Text;
TextBox t = (TextBox)sender; GridViewRow drv = (GridViewRow)t.NamingContainer; int rowIndex = drv.RowIndex; string coid = ((Label)gdvList.Rows[drv.RowIndex].FindControl("lblCoId")).Text;
要注意的是当前行中的控件只能有一个控件名为lblCoId。