tags:

views:

484

answers:

3

I'd like to use ListView to display grouped data from my db. Because of the way the query is structured, each logical group might have 1 or 2 records associated with it. Is there anyway to use GroupTemplate, while overridding the GroupItemCount behavior? Ideally, I'd like it to behave the way SQL does- assign a column ID, and let it watch for a change in value.

+1  A: 

Checkout this article on the MSDN website

Paul
A: 

I need to do exactly the same thing, I thought this would be a relatively common requirement.

My dataset that's being bound to the ListView contains one INNER JOIN. So it returns a one to many relationship. The data from the second table can relate to one record in the first table many times. A simple example would be say "Divisions" and "Employees".

So my dataset might be something like:

Division A John Smith Division A Fred Jones Division A Michael Johnson Division B Jack Jones

etc etc.

I want it to say, Group "Division A" employees together and when it discovers the data has reached "Division B", then commence a new group! So that I can use CSS/HTML to format each group nicely so they look like groups to the user.

The kind of thing I could do in about 60 seconds in PHP, ASP Classic or RoR.

Keen to know if there is a way to make the ListView more flexible to accomplish something like this quickly.

Thx a lot.

Aaron
+1  A: 

Ok here it is, nicely documented

It would be nice to build this kind of functionality directly into the control so you can simply specify this "watch" field using markup.

Again, this is the reason why I switched to the ListView, to try to avoid lengthy workarounds like this where you have to manually inject your own HTML. I bet they will eventually add this feature in and then claim how super amazing .Net 4.0 is.

All the time, more and more, I find more reasons to steer clear of inflexible .Net and use one of the more "direct" HTML manipulation platforms (PHP + CodeIgnitor). If you are absolutely fluent with CSS and HTML and know them backwards, you will find .Net uber frustrating every single time, because you just "can't quite get in there" and do what you need to do quickly without searching for workarounds all the time.

Summary: ASP.Net still isn't there yet.

Aaron