Bind nested datalist to objectdatasource

Discussion in 'ASP .Net' started by =?Utf-8?B?UGhpbA==?=, Jan 27, 2006.

  1. 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
     
    =?Utf-8?B?UGhpbA==?=, Jan 27, 2006
    #1
    1. Advertising

  2. 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/aspnet20/GridView_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
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Jan 27, 2006
    #2
    1. Advertising

  3. 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/aspnet20/GridView_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
     
    =?Utf-8?B?UGhpbA==?=, Jan 27, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevyn Twyll
    Replies:
    8
    Views:
    1,972
  2. schapopa
    Replies:
    1
    Views:
    586
    schapopa
    Jan 12, 2006
  3. H5N1
    Replies:
    0
    Views:
    2,770
  4. =?Utf-8?B?QVNQIERldmVsb3Blcg==?=

    How do you bind a datalist that is inside a bound datalist

    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=, Sep 25, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    597
    =?Utf-8?B?QVNQIERldmVsb3Blcg==?=
    Sep 26, 2006
  5. Sam Loveridge

    VS2005 DataList with Nested GridView using ObjectDataSource

    Sam Loveridge, Nov 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    590
    Steven Cheng[MSFT]
    Dec 2, 2005
Loading...

Share This Page