<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());
    }

posted on 2009-03-19 18:23  自己  阅读(3005)  评论(1编辑  收藏  举报