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>
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With