Re: Problem doing DataBind on a control within a DataList?
From: Olav Tollefsen (x_at_y.com)
Date: 12/29/04
- Next message: TBocchino: "Re: Master Pages"
- Previous message: Dimitri Glazkov: "Re: alert pop-up box when closing the browser window"
- In reply to: Eliyahu Goldin: "Re: Problem doing DataBind on a control within a DataList?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 29 Dec 2004 15:10:44 +0100
Moving the code to the ItemDataBound event handler didn't make any
difference. Seems like the problem is related to using the Visual Studio
2005 Beta 1 refresh. I tested with Visual Studio 2004 and then it worked as
expected.
Olav
"Eliyahu Goldin" <removemeegoldin@monarchmed.com> wrote in message
news:uQ0nyXa7EHA.1408@TK2MSFTNGP10.phx.gbl...
> Olav,
>
> It seems to me that you should be doing the databinding the dropdownlists
> in
> the datalist ItemDataBound event.
>
> Eliyahu
>
> "Olav Tollefsen" <x@y.com> wrote in message
> news:uSwjcOa7EHA.2572@tk2msftngp13.phx.gbl...
>> I have a Web Form with a DataList. Inside the ItemTemplate, I have a
>> DropDownList control.
>>
>> <asp:DataList ID="ProductDataList" Runat="server">
>> <ItemTemplate>
>> <asp:DropDownList ID="DropDownList1" Runat="server"
>> DataTextField="PropertyValue" DataValueField="PropertyValueId">
>> </asp:DropDownList>
>> </ItemTemplate>
>> </asp:DataList>
>>
>> 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
>>
>>
>
>
- Next message: TBocchino: "Re: Master Pages"
- Previous message: Dimitri Glazkov: "Re: alert pop-up box when closing the browser window"
- In reply to: Eliyahu Goldin: "Re: Problem doing DataBind on a control within a DataList?"
- Messages sorted by: [ date ] [ thread ]