Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP 2.0 Problem with Nesting User Control containing a GridView within a DataList

Reply
Thread Tools

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

 
 
s.gregory@4castweb.com
Guest
Posts: n/a
 
      12-06-2005
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!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control within DataList/GridView naomi ASP .Net 0 09-19-2006 11:02 AM
problem with user control containing GridView control and paging... John Smith ASP .Net 0 08-02-2006 09:18 PM
ASP 2.0 Problem with Nesting User Control containing a GridView within a DataList s.gregory@4castweb.com ASP .Net Building Controls 0 12-06-2005 05:19 PM
Module.nesting -> Kernel#nesting Trans Ruby 10 09-16-2005 12:21 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM



Advertisments