I go back and forth between repeater controls and just using good ol' string
builders to build formatted output from a db query.
I'm working on a project where I'd really like to keep all the formatting
markup on the front-end for the non-.net folks to be able to updates.
Obvioudly, a repeater control makes a lot of sense for this.
The challenge is that this is an events list, so my data may be:
10/2/07 event
10/7/07 event
11/22/07 event
12/14/07 event
The above in a repeater is easy enough, but I need to insert a month before
each item that starts in a new month. So, it needs to look like this:
October 2007
2 event
7 event
November 2007
22 event
December 2007
14 event
Any best practices for accomplishing that via a repeater control and/or
another way to keep the front-end markup on the front end (ie, not
compiled)?
I could move my if/then logic to the front end and use response.write for it
all, but that doesn't seem a very 'modern' solution.
-Darrel
Riki - 16 Dec 2007 18:14 GMT
It's called grouping.
http://www.google.com/search?q=repeater+grouping

Signature
Riki
>I go back and forth between repeater controls and just using good ol'
>string builders to build formatted output from a db query.
[quoted text clipped - 32 lines]
>
> -Darrel
Darrel - 16 Dec 2007 19:06 GMT
> It's called grouping.
>
> http://www.google.com/search?q=repeater+grouping
Interesting. It appears that there's no 'built-in' way to handle this and
that one simply need to write a control that does just this.
Not sure the current project necessitates the time/effort for this, but will
certainly add this to my list of things to explore!
-Darrel
Eliyahu Goldin - 17 Dec 2007 09:58 GMT
The way of doing this sort of things is to make an itemtemplate out of 2
rows, one for month and another for event. Then in the ItemDataBound, or
even better in the PreRender event, you can see if the event date passed
through a month boundary, you will set the month value and make the month
row visible. If the event is in the same month with the previous one, you
will make the month row hidden.

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
>I go back and forth between repeater controls and just using good ol'
>string builders to build formatted output from a db query.
[quoted text clipped - 32 lines]
>
> -Darrel