Hi,you need to bind the drop-down list in the repeater's "Repeater1_ItemDataBound" event.
This is the code for the .aspx:
<asp:Repeater ID="Repeater1" ItemType="WebApplication26.BussinessReg" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<%# Item.BussinessDetails %><br />
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
<hr />
</ItemTemplate>
</asp:Repeater>
and this is the code-behind:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
Repeater1.DataSource = new List<BussinessReg> {
new BussinessReg(){BussinessDetails = "company x", ServicesCatSub = new List<string>(){
"a","b","c","d"
}},
new BussinessReg(){BussinessDetails = "company y", ServicesCatSub = new List<string>(){
"1","2","3","4"
}}
};
Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DropDownList ls = e.Item.FindControl("DropDownList1") as DropDownList;
BussinessReg di = e.Item.DataItem as BussinessReg;
ls.DataSource = di.ServicesCatSub;
ls.DataBind();
}
}
public class BussinessReg
{
public string BussinessDetails { get; set; }
public List<string> ServicesCatSub { get; set; }
}
PS: I used asp.net 4.5 that's why i didn't use 'Container.DataItem' in the .aspx file.