Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to bind dropdownlist which is inside repeater?

I want to bind dropdownlist which is inside a repeater.my code is

 <asp:Repeater ID="rep_UnAssignComps" runat="server">
    <ItemTemplate><asp:DropDownList ID="drp_CompPropAddress" runat="server">
            </asp:DropDownList></itemTemplate></asp:Repeater>
like image 369
Ram Singh Avatar asked Sep 12 '11 13:09

Ram Singh


1 Answers

On your Repeater's ItemDatabound event use the following:

if (e.Item.ItemType == ListItemType.Item || 
         e.Item.ItemType == ListItemType.AlternatingItem)
{

    ((DropDownList)e.Item.FindControl("drp_CompPropAddress")).DataSource =(DataRowView) e.Item.DataItem;//Or any other datasource.
    ((DropDownList)e.Item.FindControl("drp_CompPropAddress")).DataBind();

}
like image 167
Guilherme de Jesus Santos Avatar answered Sep 28 '22 01:09

Guilherme de Jesus Santos