如题,请问一下嵌套的REPEATER控件怎么去遍历它啊?谢谢<asp:repeater id ="r1" runat = server>
<ItemTemplate>
                <asp:repeater id ="r2" runat = server>
               <ItemTemplate>
                
               </ItemTemplate>
               </asp:repeater>
</ItemTemplate>
</asp:repeater>

解决方案 »

  1.   

    想根据数据库的值判断子repeater控件上的checkbox,
    并根据chekbox是否选择再插入数据库相应的字段
      

  2.   

    <asp:DataList ID="dlUserPopedom" runat="server" OnItemDataBound="dlUserPopedom_ItemDataBound" DataKeyField="i_oid">
                                        <HeaderTemplate>
                                            <span style="width:190">&nbsp;用户权限</span>
                                            <span>用户权限子功能</span>
                                        </HeaderTemplate>
                                        <HeaderStyle Font-Bold="true" BackColor="gold" />
                                        <ItemTemplate>
                                            <table>
                                                <tr>                                                                                            
                                                    <td style="width:100">
                                                        <asp:Label ID="lblName1" runat="server"></asp:Label>                                            
                                                    </td>
                                                    <td align="right">
                                                        <asp:DropDownList ID="ddlCanUsing1" runat="server">
                                                            <asp:ListItem Value="0">可以使用</asp:ListItem>
                                                            <asp:ListItem Value="1">不可使用</asp:ListItem>
                                                            <asp:ListItem Value="2">不可编辑</asp:ListItem>
                                                        </asp:DropDownList>                                                                                                  
                                                    </td>
                                                    <td>
                                                        <asp:DataList ID="dlPopedomFuns" runat="server" OnItemDataBound="dlPopedomFuns_ItemDataBound" DataKeyField="i_oid">
                                                            <ItemTemplate>
                                                                <table>
                                                                    <tr>                                                                    
                                                                        <td style="width:80">
                                                                            <asp:Label ID="lblName2" runat="server"></asp:Label>
                                                                        </td>
                                                                        <td align="right">
                                                                            <asp:DropDownList ID="ddlCanUsing2" runat="server">
                                                                                <asp:ListItem Value="0">可以使用</asp:ListItem>
                                                                                <asp:ListItem Value="1">不可使用</asp:ListItem>
                                                                                <asp:ListItem Value="2">不可编辑</asp:ListItem>
                                                                            </asp:DropDownList>  
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </ItemTemplate>
                                                        </asp:DataList>
                                                    </td>
                                                </tr>                                            
                                            </table>
                                        </ItemTemplate>
                                        <ItemStyle BackColor="AntiqueWhite" BorderWidth="5" />
                                        <AlternatingItemStyle BackColor="AliceBlue" BorderWidth="5"/>
                                    </asp:DataList>----------------------------------------------------------------------------------------//
    protected static DataList dlPopedomFuns = null;//全局变量foreach (DataListItem popedomItem in this.dlUserPopedom.Items)
            {
                int popedomOID = int.Parse(this.dlUserPopedom.DataKeys[popedomItem.ItemIndex].ToString());
                //保存用户权限设置
                DropDownList ddlCanUsing1 = (DropDownList)popedomItem.FindControl("ddlCanUsing1");
                Popedom popedom = new Popedom(popedomOID);
                popedom.Recover();
                popedom.CanUsing = (PopedomUsability)ddlCanUsing1.SelectedIndex;
                popedom.Save();
                //保存用户权限子功能设置
                dlPopedomFuns = (DataList)popedomItem.FindControl("dlPopedomFuns");
                foreach (DataListItem funItem in dlPopedomFuns.Items)
                {
                    int funsOID = int.Parse(dlPopedomFuns.DataKeys[funItem.ItemIndex].ToString());
                    DropDownList ddlCanUsing2 = (DropDownList)funItem.FindControl("ddlCanUsing2");
                    Popedomfuns funs = new Popedomfuns(funsOID);
                    funs.Recover();
                    funs.CanUsing = (PopedomUsability)ddlCanUsing2.SelectedIndex;
                    funs.Save();
                }
            }//这个是DataList的实例,repeater是一样的
      

  3.   

    foreach (DataListItem popedomItem in this.dlUserPopedom.Items)
    {
       foreach (DataListItem funItem in dlPopedomFuns.Items)
    }------------这样在子遍历时好象认不到dlPopedomFuns这个ID哦
      

  4.   

    呵呵,不过还是谢谢了,受此启发
    foreach(RepeaterItem item in this.Repeater1.Items)
    {
    foreach(RepeaterItem item2 in ((Repeater)item.FindControl("Repeater2")).Items )
    {
    }
    }
    已调试成功.我菜,现在才知道原来遍历也可以嵌套哇!!!!!!
      

  5.   

    遍历也可以嵌套哇!!!!!!??
    for
    {
        for{}}
    for能欠套foreach为啥不能欠套