473,395 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Render Data By Group

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
Oct 27 '06 #1
2 1312
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:
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
Oct 28 '06 #2
Michael Hamrah wrote:
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
Oct 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: AbeR | last post by:
I'm an intermediate/novice (I've probably developed a half dozen ASP.NET apps at this point) ASP.NET C# developer at this point and am totally strumped by a client's setup. I am developing this...
5
by: aboycalled3 | last post by:
I'm interested in using the fascinating CSS available at http://www.moronicbajebus.com/playground/cssplay/reformat-table/ which allows one to present tabular data in a way that's more appealing...
1
by: Lau Lei Cheong | last post by:
Hello, I'm writing a web page using ASP.NET that with send the page's HTML content to user through e-mail. My plan is to dump the content to a file then email it to user as attachment. The...
2
by: Frank | last post by:
Hi all, I want to derive a class from DataGrid so that I can have a label on the top. But when I tried to add the control to my form, I got an error "Specified cast is not valid" on the line:...
2
by: Darren Clark | last post by:
I am trying to work out how to change some values of data during itemdatabound. MSDN states that the ItemDataBound is called BEFORE the render... so any changes do the data SHOULD work.. ...
1
by: WT | last post by:
Hello, I recently discovered that Page.Render is doing special things concerning the Menu navigation control. When I was using my own Render override, menus were not working, maybe some style...
0
by: Raghu | last post by:
Hi All, I am building Report application using ASP.Net and C#. The report will be shown to the user in aspx page. The report inputs are taken at runtime like columns user wants to see and...
7
by: SteveM | last post by:
I am sure this is an easy question, but being relatively new to ASP.NET programming, I can not quite grasp what I need to accomplish what I need to do. What I have is a word document that is...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.