O
Olav Tollefsen
I have a Web Form with a DataList. Inside the ItemTemplate, I have a
DropDownList control.
<asp
ataList ID="ProductDataList" Runat="server">
<ItemTemplate>
<asp
ropDownList ID="DropDownList1" Runat="server"
DataTextField="PropertyValue" DataValueField="PropertyValueId">
</asp
ropDownList>
</ItemTemplate>
</asp
ataList>
In the Page_Load for the Web Form, I do the following:
1) First I bind the DataList control to a data source.
ProductDataList.DataSource = product;
ProductDataList.DataBind();
2) Then I try to bind the DropDownList control to a data source:
DropDownList dropdown1 =
(DropDownList)ProductDataList.Items[0].FindControl("DropDownList1");
dropdown1.DataSource = propertyValues;
dropdown1.DataBind();
The code executes fine and I can see that the data source in step 2 is
containing the correct values that should be displayed in the DropDownList
control.
The problem is that the DropDownList control is empty. If I do exactly the
same with a DropDownList control that is placed on the Web Form outside the
DataList control, everything works just as expected.
Any hints on how to solve this problem?
Olav
DropDownList control.
<asp
<ItemTemplate>
<asp
DataTextField="PropertyValue" DataValueField="PropertyValueId">
</asp
</ItemTemplate>
</asp
In the Page_Load for the Web Form, I do the following:
1) First I bind the DataList control to a data source.
ProductDataList.DataSource = product;
ProductDataList.DataBind();
2) Then I try to bind the DropDownList control to a data source:
DropDownList dropdown1 =
(DropDownList)ProductDataList.Items[0].FindControl("DropDownList1");
dropdown1.DataSource = propertyValues;
dropdown1.DataBind();
The code executes fine and I can see that the data source in step 2 is
containing the correct values that should be displayed in the DropDownList
control.
The problem is that the DropDownList control is empty. If I do exactly the
same with a DropDownList control that is placed on the Web Form outside the
DataList control, everything works just as expected.
Any hints on how to solve this problem?
Olav