如何访问HeaderTemplate中的控件

在DataGrid的ItemCreated事件中   
   if    (e.Item.ItemType==ListItemType.Header)   
   {   
   ((LinkButton)e.Item.Cells[i].Controls[1]).Text="haha";   
   }   
  
   
   1.datagrid.Controls(0)    是{System.Web.UI.WebControls.DataGridTable}   
   2.datagrid.Controls(0).Controls(i)    是第i行   
       相当于ItemCreated、ItemCommand事件中的e.Item   
   3.datagrid.Controls(0).Controls(i).Controls(j)    是第i行,第j+1列(0行一般是表头)   
       相当于ItemCreated、ItemCommand事件中的e.Item.cells(j)   
   4.datagrid.Controls(0).Controls(i).Controls(j).Controls(k)    是第i行,第j+1列,第k+1个控件     
       相当于ItemCreated、ItemCommand事件中的e.Item.Cells(j).Controls(k)   
   5.或   
       datagrid.Controls(0).Controls(i).Controls(j).FindControls("cid")   
       相当于ItemCreated、ItemCommand事件中的e.Item.Cells(j).FindControls("cid")   
posted @ 2008-03-01 15:29  dodo-yufan  阅读(1011)  评论(0编辑  收藏  举报