ジェネリックにバインドされたリピーター コントロールがありList<>
ます。
リピーターのアイテムはすべて独自の<div>
タグに含まれているため、すべてのアイテムの標準的なプレースホルダーと同様に、優れたブロック視覚効果が得られます.
カスタム ソートを使用して、結果を独自の標準に並べることができましたが、標準ではないものが必要になりました。
<div>
ブロックで選択したアイテムを取得し、リピーターのアイテム リストの一番下または一番上に移動できるようにする必要があります。
これを行う方法はありますか?バインドするか、リピーターのrepeater_ItemDataBound()
方法を使用しますか?
コードはかなり長いので、「知っておく必要がある」と思われるものを投稿します。
ジェネリック リストの作成
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")
});
}
-同じ方法- データを並べ替えてからバインドする
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();
ジェネリック リスト クラス (並べ替えあり)
/// <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; }
}
私の質問の実世界への適用 「スティッキー」一致がある場合-日付、ステータス、または名前に関係なく、一致の上に表示される必要があります