GridView模板列中的TextBox的ontextchanged事件中获取当前行的某列!

 

  GridView模板列有一TextBox,TextBox的AutoPostBack属性为True,在TextChanged事件中可通过如下代码获取当前行某列的值:

C#代码 复制代码
  1.      TextBox t = (TextBox)sender;   
  2.         GridViewRow drv = (GridViewRow)t.NamingContainer;   
  3.         int rowIndex = drv.RowIndex;   
  4.         string coid = ((Label)gdvList.Rows[drv.RowIndex].FindControl("lblCoId")).Text;  


  要注意的是当前行中的控件只能有一个控件名为lblCoId。
posted @ 2009-12-29 15:06  mysun  阅读(457)  评论(0编辑  收藏  举报