能看代码的CrackLibby

程序猿的2货

[.Net码农]Repeater嵌套dropdownlist控件

http://www.cnblogs.com/345563452/archive/2009/03/19/1417037.html




<asp:repeater id="Repeater1" runat="server"onitemdatabound="Repeater1_ItemDataBound">
            
<itemtemplate>
            
<div>
                
<asp:dropdownlist id="drpUserList" autopostback="true"onselectedindexchanged="myDrop_SelectedIndexChanged" runat="server"></asp:dropdownlist>
            
</div>
            
</itemtemplate>
        
</asp:repeater>

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        
if (e.Item.ItemType ==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
        {
            DropDownList myDrop 
= e.Item.FindControl("drpUserList"as DropDownList;
            
if (myDrop.Items.Count == 0)
            {
                myDrop.Items.Add(
new ListItem("a""1"));
                myDrop.Items.Add(
new ListItem("b""2"));
                myDrop.DataBind();
            }
        }
    }

    
protected void myDrop_SelectedIndexChanged(object sender,EventArgs e)
    {
        Response.Write(((DropDownList)sender).SelectedIndex.ToString());
    }

分类: ASP.NET

阅读更多
个人分类: .Net码农
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭