Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8763251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:44:21+00:00 2026-06-13T15:44:21+00:00

I have a repeater control binded to a generic List<> . The repeaters’ items

  • 0

I have a repeater control binded to a generic List<>.

The repeaters’ items are all in its own <div> tag, so it gives a good block visual effect, as well as a standard placeholder for all the items.

With custom sorting, I have been able to arrange the results among its own standard, but now I need something that isn’t standard.

I need to be able to take a selected item in a <div> block, and move it either to the bottom or the top of the repeaters’ item list.

Is there any way I am able to do this? Either by binding, or using the repeaters’ repeater_ItemDataBound() method?

The code is quite long.. So I will post what I think would be the ‘need to know’.

Populating the generic list

                        while (rdr.Read())
                        {
                            challenge.Add(new ChallengeList
                                {
                                    GameName = rdr["gameName"].ToString(),
                                    CreatorName = rdr["creatorName"].ToString(),
                                    MediatorName = rdr["mediatorName"].ToString(),
                                    ChallengeID = rdr["challengeId"].ToString(),
                                    ChallengeAccepted = rdr["accepted"].ToString(),
                                    MatchDate = DateTime.Parse(rdr["matchDate"].ToString()).ToString("dd MMMM yyyy hh:mm")
                                });
                        }

-Same Method- Sorting the data, then binding

    switch (sort)
    {
        case "name":
            Comparison<ChallengeList> name = ChallengeList.CompareGameName;
            challenge.Sort(name);
            break;

        case "date":
            Comparison<ChallengeList> date = ChallengeList.CompareDate;
            challenge.Sort(date);
            break;

        case "status":
            Comparison<ChallengeList> status = ChallengeList.CompareStatus;
            challenge.Sort(status);
            break;
    }

    rptChallenges.DataSource = challenge;
    rptChallenges.DataBind();

Generic List Class (With sorting)

/// <summary>
/// Class ChallengeList
/// With sorting
/// </summary>
public class ChallengeList
{
    /// <summary>
    /// Compares the name of the game.
    /// </summary>
    /// <param name="game1">The game1.</param>
    /// <param name="game2">The game2.</param>
    /// <returns>System.Int32.</returns>
    public static int CompareGameName(ChallengeList game1, ChallengeList game2)
    {
        return String.Compare(game1.GameName, game2.GameName, StringComparison.Ordinal);
    }

    /// <summary>
    /// Compares the status.
    /// </summary>
    /// <param name="status1">The status1.</param>
    /// <param name="status2">The status2.</param>
    /// <returns>System.Int32.</returns>
    public static int CompareStatus(ChallengeList status1, ChallengeList status2)
    {
        return string.Compare(status1.ChallengeAccepted, status2.ChallengeAccepted, StringComparison.Ordinal);
    }

    /// <summary>
    /// Compares the date.
    /// </summary>
    /// <param name="date1">The date1.</param>
    /// <param name="date2">The date2.</param>
    /// <returns>System.Int32.</returns>
    public static int CompareDate(ChallengeList date1, ChallengeList date2)
    {
        return string.Compare(date1.MatchDate, date2.MatchDate, StringComparison.Ordinal);
    }

    /// <summary>
    /// Compares the date reverse.
    /// </summary>
    /// <param name="date2">The date2.</param>
    /// <param name="date1">The date1.</param>
    /// <returns>System.Int32.</returns>
    public static int CompareDateReverse(ChallengeList date2, ChallengeList date1)
    {
        return string.Compare(date1.MatchDate, date2.MatchDate, StringComparison.Ordinal);
    }

    /// <summary>
    /// Gets or sets the name of the game.
    /// </summary>
    /// <value>The name of the game.</value>
    public string GameName { get; set; }
    /// <summary>
    /// Gets or sets the name of the creator.
    /// </summary>
    /// <value>The name of the creator.</value>
    public string CreatorName { get; set; }
    /// <summary>
    /// Gets or sets the name of the mediator.
    /// </summary>
    /// <value>The name of the mediator.</value>
    public string MediatorName { get; set; }
    /// <summary>
    /// Gets or sets the challenge ID.
    /// </summary>
    /// <value>The challenge ID.</value>
    public string ChallengeID { get; set; }
    /// <summary>
    /// Gets or sets the challenge accepted.
    /// </summary>
    /// <value>The challenge accepted.</value>
    public string ChallengeAccepted { get; set; }
    /// <summary>
    /// Gets or sets the match date.
    /// </summary>
    /// <value>The match date.</value>
    public string MatchDate { get; set; }
}

Real-world application of my question
If there is a ‘stickied’ match – it must appear on top of the matches regardless of date, status or name

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:44:23+00:00Added an answer on June 13, 2026 at 3:44 pm

    I would recommend that you order the data in your list before you see ditto the repeater. If this is not possible given structure of your data and/or the item template of the repeater, could you please include samples of the data and the repeater so that we may help further?

    EDIT after asker posted code

    rather than setting challenge as the data source for the repeater you should separate all the items that need to be on the top of the list into a new list and then append the other other items to the end of the top items.

    something like this:

    var topItmes = new List<ChallengeList>();
    var otherItmes = new List<ChallengeList>();
    
    foreach (var item in challenge)
    {
        if(/*item needs to be on top*/)
        {
            topItmes.Add(item);
        }
        else
        {
            otherItmes.Add(item);
        }
    }
    
    topItmes.AddRange(otherItmes);
    

    depending on what the criteria is for an item to be on the top, you may be able to use a LINQ expression to simplify this code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Repeater Control and in that i have code like this <div runat=server
I have the following Repeater control to display a list of elements. <td id=tdLeftBlock>
I have a repeater control that generates a list of links from a SqlReader.
I have a Repeater control who has its dataSource setted with a typed object
I have a page (category-list.apsx) that uses the Repeater Control method to display the
I have a repeater control and some controls like dropdown/Buttons/Checklist for search as all
I have a .NET repeater control that is data-bound to a List. As part
I have a nested repeater control that displays a list of data, in my
I have a Repeater Control using an XMLDataSource to produce a list of movies
I have two Repeater Control var list = from i in DA.obm_view_studentLists where i.FranchiseID

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.