Ram Singh Ram Singh - 1 year ago 118
ASP.NET (C#) Question

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">

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download