473,411 Members | 1,949 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,411 software developers and data experts.

Bind nested datalist to objectdatasource

I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasource (ObjectDataSource1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasource
(ObjectDataSource2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks
Jan 27 '06 #1
2 3396
Make sure that the datasource for DataList2 is within the same template that
the DataList2 is placed, because for each datalist2 instance there will be an
instance of the datasource created. I have a demo that achieved the same
declaratively albeit using a parent GridView that expands a child GridView
that in turn expands a DetailsView.
http://www.webswapp.com/CodeSamples/...idView_1c.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phil" wrote:
I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasource (ObjectDataSource1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasource
(ObjectDataSource2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks

Jan 27 '06 #2
Thanks for the reply. I didn't realize that the position of the
objectdatasource control mattered, but apparently it does. The only
difference here is that I wanted to do the databinding without a selection
occuring (meaning there is no SelectedIndex for me to reference). I solved
this problem by putting a Label control in the first datalist and binding the
text property to the categoryId (but made the label control hidden). Then I
used the controlparameter of the second object datasource and referenced the
text property of the label.

I read that part of the solution last night somewhere, don't remember where
as I wasn't able to get it working then (likely due to the position of the
datasource control).

All-in-all, everything seems to be working now. Thanks again for the reply,
and nice samples on your site there.

Thanks.

"Phillip Williams" wrote:
Make sure that the datasource for DataList2 is within the same template that
the DataList2 is placed, because for each datalist2 instance there will be an
instance of the datasource created. I have a demo that achieved the same
declaratively albeit using a parent GridView that expands a child GridView
that in turn expands a DetailsView.
http://www.webswapp.com/CodeSamples/...idView_1c.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phil" wrote:
I have a datalist (DataList1)...
with an itemtemplate...
then a table - server side (Table1)...
then another datalist (DataList2)...
another itemtemplate...
another table - server side (Table2)

DataList1 is bound to an objectdatasource (ObjectDataSource1), and has a
datakey (CategoryId). I want to bind DataList2 to another objectdatasource
(ObjectDataSource2), pulling records based on DataList1's datakey
(CategoryId).

I've set everything up, but when i run the page only DataList1 appears to
databind. Table1 renders out, but DataList2 never seems to databind.

I'm trying to do everything declaritively, is that possible? If so, what am
I doing worng?

Thanks

Jan 27 '06 #3

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

Similar topics

3
by: Derek | last post by:
I have a nested datalist with a dropdownlist. I need to capture the selectedvalue of the dropdownlist so I can update a database table. My question then is...how do I get the value from the...
0
by: H5N1 | last post by:
Hi there My problem is that in when I update GridView row, which is nested into DataList control, I want to refresh also DataList in which the GridView is nested, since after update, trigger in...
1
by: H5N1 | last post by:
Hello everybody I'm stuck for a long time with the following problem, so I will be really gratefull if you could help me a bit: I have a GridView nested in DataList (it's located in DataList's...
1
by: Jules | last post by:
We have a problem setting, actually resetting, the SelectedItemTemplate of a DataList control. Below is the ObjectDataSource and the DataList in .ASPX: <asp:ObjectDataSource ID="mySource"...
0
by: TheDude5B | last post by:
HI, I am creating a DataList by using the SelectMethod from an ObjectDataSource. Within each item I want to be able to the dynamically create a drop down list depending on what the ProductID is...
0
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check...
0
by: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea">...
1
by: Mark Micallef | last post by:
Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm...
0
by: nzkks | last post by:
Hi, I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Objectdatasource using DAL & BLL classes My objectdatasource can produce below output by CategoryID parameter:...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.