Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

if/then logic in a repeater control. best methods?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Darrel - 16 Dec 2007 17:14 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.