ASP 2.0 Problem with Nesting User Control containing a GridView within a DataList

Discussion in 'ASP .Net Building Controls' started by s.gregory@4castweb.com, Dec 6, 2005.

  1. Guest

    My page layout is like this:

    Page
    >DataList (databound using ObjectDataSource1 contained in page)
    >>Items
    >>>UserControl
    >>>>GridView (databound using another ObjectDataSource2 contained in UserControl)


    So I've basically got a GridView (wrapped in a UserControl), that is
    nested within a DataList. Representing a fairly simple relational data
    structure (see bottom of post).

    In ASP 1.x I would then pass the ID's that are required to lookup the
    GridView data to the child UserControl in the DataList_ItemDataBound
    event in order for it to know what to render.

    Attempting this in ASP 2.0 gives me problems, because when the
    UserControl is created by the datalist, it automatically invokes the
    GridView's databinding (straight after the Page_Load of the
    UserControl) BEFORE the ID's needed to perform the rowset lookup have
    had a chance to be passed in by the parent DataList.

    If I do this without the UserControl, it works (i.e. if I put
    ObjectDataSource2 and the GridView directly into the parent DataList).
    But this obviously isn't what I want!!

    Has anybody got any ideas on how to get back the control that has
    seemingly been taken away from me?

    Surely it's possible to stop this automatic databinding from
    happening?!!



    FYI Data Structure:

    There are three main tables related to this scenario:

    ServiceTypes (PK ID)
    Services (PK ID, FK ServiceTypeID)
    UserServices (PK GUID, FK ServiceID, UserGUID)

    The DataList is bound to the ServiceTypes table with no filter (via
    ObjectDataSource1).
    The ServiceTypes PK (ID) is passed to the UserControl (along with a
    UserGUID), to perform the following filter on the UserServices Table
    (via ObjectDataSource1):

    "[UserGUID] = '" & uiUserGUID.ToString & "' AND
    Parent(ServicesServiceUsers).[ServiceTypeID] = " &
    iServiceTypeID.ToString

    Both ObjectDataSources are pointing to a custom business object that
    I've written to wrap & manage a strongly typed dataset (another thing
    I've had to resort to in order to get this stuff to work properly, as I
    can't seem to get anywhere by binding directly to it!!!)




    I'm really trying to give all these new databinding controls the
    benefit of the doubt, but I keep coming across major restrictions
    whichever way I turn. It's obviously very simple to set up a basic grid
    for editing a flat table, but nearly all of the scenarios I come across
    are so much more complicated than that, but seem to be much more
    difficult to do than ASP 1.x, within the confines of the new
    databinding structure of ASP 2.0!
     
    , Dec 6, 2005
    #1
    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,961
  2. Replies:
    0
    Views:
    1,483
  3. John Smith
    Replies:
    0
    Views:
    1,017
    John Smith
    Aug 2, 2006
  4. naomi
    Replies:
    0
    Views:
    571
    naomi
    Sep 19, 2006
  5. Trans
    Replies:
    10
    Views:
    326
    Sean O'Halpin
    Sep 16, 2005
Loading...

Share This Page