473,698 Members | 2,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
Dec 16 '07 #1
3 1270
It's called grouping.

http://www.google.com/search?q=repeater+grouping

--

Riki

"Darrel" <no*****@nospam .comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>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

Dec 16 '07 #2
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
Dec 16 '07 #3
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.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Darrel" <no*****@nospam .comwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
>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

Dec 17 '07 #4

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

Similar topics

5
5442
by: UnknownServices | last post by:
I've added a LinkButton to a repeater control and I set the link button as follows: <asp:LinkButton ID="DLLinkButton" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "DownloadID")%>' Runat=server CommandName="DLCount" >Download Now!</asp:LinkButton> When I click this button it dosen't do anything instead of calling the function I created.
4
1800
by: bill | last post by:
I have a Repeater control in a web user control. The web user control has a public method named PopulateRepeater which takes an ID as an parameter and populates the repeater control based on the parameter. When I call PopulateRepeater from the User Control page_load event it populates the repeater without a problem. When I call PopulateRepeater from a procedure in the web form which contains
8
3022
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
7
3003
by: | last post by:
I have what's probably a simple page lifecycle question related to dynamically evaluating values that are placed by a repeater and dynmically placing user controls that use those values. I'm attempting to bind a user control I've written, "ImageBox", to a repeater. The user control takes a custom property, "ContentID", that will execute a database lookup and load an image.
5
3848
by: Brad Baker | last post by:
I am trying to make a "tabbed" interface by iterating through a dataset with a conditional statement. For example: ---------------------------------------------------------------------------------------------------------------------- | <a href="config.aspx?siteid=FIEJGIE">Site 1</a| Site 2 | <a href="config.aspx?siteid=DFOWEMF">Site 3</a>| In the example above site 2 is the "current" tab. I have the following code at the top of my...
12
1595
by: Bob Jones | last post by:
I have an odd business requirement and I think that the implementation is not correct in the terms of OOP development. Any help on the concepts would be very appreciated! We currently have a custom Page object which is derived from the base Page object. We also have custom controls that derive from a base class that performs custom drawing and inherits from our own IOurControl interface. There is also a special caching layer in the mix...
6
3757
by: Doogie | last post by:
I have a Repeater control in an app I'm updating. I need to write code (event method) when a user clicks on one of the columns in the control. But there is no method like "Repeater_OnClick" or something like that. Is there a way to get access to this control with an event method of some kind? If not, (and here's where my inexperience in web development will show through), is there another server side grid type control that I could...
1
2002
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I'm trying to figure out how you do the most basic Data-Bound "Repeater" functionality on a Mobile ASPX page. I don't mean a list box, because it will have repeated HTML and User Controls in each Row. How do I do this, please? Thanks! Alex
15
3910
by: | last post by:
I dynamically create controls (textboxes) in a repeater control. I know their names (eg. TextBox1). How do I find the text of TextBox1 in the Form? FindControl does not seem to work.
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.