请问各位高手,如何得到Repeater里面下拉框的值

解决方案 »

  1.   

    绑定的时候用服务器控件 
    提交到页面后 遍历Repeater的每一项
    foreach (RepeaterItem item in ("Repeater的ID").Items) 

        Control control = item.FindControl("控件ID") as "控件的类型" //找出下拉框
        任意操作...... 
    }
      

  2.   


    控件的类型 control = item.FindControl("控件ID") as "控件的类型" //找出下拉框这样会更好一点吧? 
      

  3.   

    一、在Repeater数据绑定的时候判断:<html>
    <body>
        <form id="form1" runat="server">
            <asp:Repeater runat="server" ID="repeater" OnItemDataBound="repeater_ItemDataBound">
                <ItemTemplate>
                    <asp:DropDownList runat="server" ID="ddl">
                    </asp:DropDownList >
                </ItemTemplate>
            </asp:Repeater>
        </form>
    </body>
    </html>
    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DropDownList ddl= e.Item.FindControl("ddl") as DropDownList;
        foreach (ListItem item in ddl.Items)
        {
            //item就是你想要的东西了
        }
    }二、在Repeater控件之外访问: /// <summary>
    /// 获取Repeater中CheckBoxList的选中项
    /// </summary>
    /// <returns></returns>
    private void GetCheckListSeletedItems()
    {
        foreach (RepeaterItem ritem in this.repeater.Items)
        {
            DropDownList ddl = ritem.FindControl("ddl") as DropDownList;
            foreach (ListItem item in ddl.Items)
            {
              //item就是你想要的东西了
            }
        }
    }