Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Repeater - property to appear only once

Vote:
 

Hi!

I'm using a repeater for a listing (of pages). The list consists of posts/pages and I'm using the property Division for heading (they are sorted by this property). Since I want the heading only to appear once I've come up with the function below. It works but I wonder if there is another (more simple) way to retrieve a property and only display it once (first time when sorted) when using a repeater?

public string checkDiv(PageData thePage)
        {
            if (lastPage!=null)
            {
                if ((string)lastPage["Division"] != (string)thePage["Division"])
                {
                    lastPage = thePage;
                    return "<tr><td colspan=\"4\">" + thePage["Division"] + "</td></tr>";
                }
                else
                {
                    lastPage = thePage;
                    return "";
                }
            }
            else
            {
                lastPage = thePage;
                return "<tr><td colspan=\"4\">" + thePage["Division"] + "</td></tr>";
            }
        }

    

 

 

#73786
Aug 09, 2013 11:32
Vote:
 

I would most probably be looking in some simple PageData collection grouping and then iterating over group keys. Such groups are pretty easy doable in Linq. You may end up with double repeaters: one for group keys (distinct values of Division property) other for pages itself. Don't think that would be simpler approach :)

#73793
Aug 09, 2013 15:09
Vote:
 

Ah okey! Thanks for the reply... I'll stick with the above method for the time being :)

#73821
Aug 12, 2013 8:38
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.