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
}
[quoted text, click to view] senfo wrote:
> 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