查找DataGrid中的模板控件

html代码:

<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False" onitemcreated="DataGrid1_ItemCreated" onitemdatabound="DataGrid1_ItemDataBound">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox Runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"item")%>' ID="itemCB" AutoPostBack="True">
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBoxList Runat="server" ID="dqdmCBL" RepeatDirection="Horizontal" RepeatColumns="7" AutoPostBack="true"></asp:CheckBoxList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>

要找到以上的两个控件代码:

for (int t = 0; t < DataGrid1.Items.Count; t++)            

{

CheckBoxList cbl = (CheckBoxList)DataGrid1.Items[i].FindControl("dqdmCBL");

CheckBox chk = (CheckBox)DataGrid1.Items[i].FindControl("itemCB");

posted @ 2011-05-24 08:46  xfyn  阅读(222)  评论(0编辑  收藏  举报