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

S

s.gregory

My page layout is like this:

Page
DataList (databound using ObjectDataSource1 contained in page)

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top