469,363 Members | 2,578 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,363 developers. It's quick & easy.

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 3255
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Derek | last post: by
1 post views Thread by H5N1 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.