HighTechTalks DotNet Forums  

Render Data By Group

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Render Data By Group in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
senfo
 
Posts: n/a

Default Render Data By Group - 10-27-2006 , 11:35 AM






I've been trying to come up with a way to use the built in ASP.NET
controls to design something that displays the results of a database
query by group like is possible in an Access report to, for example,
display a list of managers and all of their employees. For example:

Type 1
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Type 2
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Type 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
[...]

So far, I have come up short on ideas to implement this cleanly using
the ASP.NET controls. A friend of mine suggested a Repeater with
another Repeater nested inside of it; however, it just didn't seem like
a clean way.

I've considered developing my own custom server control that extends the
CompositeDataBoundControl class, but even doing this, I couldn't think
of a clean way of doing it without requiring two DataSource properties
(one for the Managers and another for the Employees).

I'm sure others have run across a similar situation in the past; but, I
haven't had any luck locating any examples.

Does anybody have any suggestions?

Thank you in advance,

--
Sean

Reply With Quote
  #2  
Old   
Michael Hamrah
 
Posts: n/a

Default Re: Render Data By Group - 10-27-2006 , 10:37 PM






Hey Sean,
I think the CompositeDataBoundControl is definitely the way to go- and
you don't need two datasource properties. The trick here is loose
casting in the CreateChildControl function. What you want to do is
enumerate through the datasource like you would do for a flat control,
and add a row or whatever container you wanted for that primary row in
the datasource. Then, when you have your enumerated element, you can
see if that implements the IList, IListSource, or the IEnumerable
interface. If it does, you can get an enumerator from that element and
loop it just like you were doing for the primary datasource. With this
secondary list you can build your sub grid.

You may want to add some properties to help the composite control find
the child controls in the datasource. Say, if the datasource is a
dataset you can add some props to help the CreateChildControl function
find relationships with datatables to access sub data.

Here's some psuedocode:

Enumerator ie = this.DataSource.GetEnumerator();
foreach(element in ie)
{
row = BuildRow();
if(element is IEnumerator)
{
IEnumerator AnotherEnumerator = element.GetEnumerator();
BuildTableInRow(row, AnotherEnumerator); //This Builds the sub
table
}


senfo wrote:
Quote:
I've been trying to come up with a way to use the built in ASP.NET
controls to design something that displays the results of a database
query by group like is possible in an Access report to, for example,
display a list of managers and all of their employees. For example:

Type 1
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Type 2
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Type 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
Column 1, Column 2, Column 3
[...]

So far, I have come up short on ideas to implement this cleanly using
the ASP.NET controls. A friend of mine suggested a Repeater with
another Repeater nested inside of it; however, it just didn't seem like
a clean way.

I've considered developing my own custom server control that extends the
CompositeDataBoundControl class, but even doing this, I couldn't think
of a clean way of doing it without requiring two DataSource properties
(one for the Managers and another for the Employees).

I'm sure others have run across a similar situation in the past; but, I
haven't had any luck locating any examples.

Does anybody have any suggestions?

Thank you in advance,

--
Sean


Reply With Quote
  #3  
Old   
senfo
 
Posts: n/a

Default Re: Render Data By Group - 10-31-2006 , 10:35 AM



Michael Hamrah wrote:
Quote:
Hey Sean,
I think the CompositeDataBoundControl is definitely the way to go- and
you don't need two datasource properties. The trick here is loose
casting in the CreateChildControl function. What you want to do is
enumerate through the datasource like you would do for a flat control,
and add a row or whatever container you wanted for that primary row in
the datasource. Then, when you have your enumerated element, you can
see if that implements the IList, IListSource, or the IEnumerable
interface. If it does, you can get an enumerator from that element and
loop it just like you were doing for the primary datasource. With this
secondary list you can build your sub grid.

You may want to add some properties to help the composite control find
the child controls in the datasource. Say, if the datasource is a
dataset you can add some props to help the CreateChildControl function
find relationships with datatables to access sub data.

Here's some psuedocode:

Enumerator ie = this.DataSource.GetEnumerator();
foreach(element in ie)
{
row = BuildRow();
if(element is IEnumerator)
{
IEnumerator AnotherEnumerator = element.GetEnumerator();
BuildTableInRow(row, AnotherEnumerator); //This Builds the sub
table
}

Hi Michael,

Thank you very much for the response. I've been busy at work with my
primary job (this question was in reference to a side project), so I
haven't had an opportunity to try to implement it, yet.

I think I have an idea of what you're suggesting, but I won't find out
for sure until this evening or tomorrow evening. I'll definitely write
back if I have any follow-up questions.

Thank you again,

--
Sean


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.