469,946 Members | 1,771 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

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

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 '05 #1
0 1532

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Glenn Owens | last post: by
reply views Thread by manu_srinivasa | last post: by
9 posts views Thread by Jakob Lithner | last post: by
3 posts views Thread by igotyourdotnet | last post: by
5 posts views Thread by Josh Nikle | last post: by
1 post views Thread by Salim | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.