473,416 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Problem doing DataBind on a control within a DataList?

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
Nov 19 '05 #1
2 2189
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:uS**************@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

Nov 19 '05 #2
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" <re*************@monarchmed.com> wrote in message
news:uQ**************@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:uS**************@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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
3
by: Lerp | last post by:
Hi all, I am building an app that has a lot of one to many relationships and was curious as to the best method in displaying rows of data from both tables on the same line. ie: row1 of...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
3
by: J'son | last post by:
Guys, I have created a custom class that derives from DataList so that I can add some custom client side functionality into each new item row (<td>). Heres the class in its simplest form: ...
1
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing...
0
by: AleXmanFree | last post by:
Hi, I have this kind of problem, In my asp.net page i use DataList and user control that is repeated in DataList. This user control has in it a checkbox , so everytime user clicks on checkbox...
0
by: nicklang | last post by:
Say you are creating a page which contains a child control which uses a DataList or DataGrid control. In a DataList, the rows are dynamic controls and are data bound, so you have to first load the...
5
by: Aussie Rules | last post by:
Hi, I am still having a problem using a datalist control using VB.net This is my code...... In the HTML page I have <asp:DataList ID="DataList1" runat="server">
0
by: Bieniu | last post by:
I have DataList control on my own contro land it is bind to SqlDataSource control. My problem is that DataList is getting needed data twice what is for me very strange. I have some code in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.