当前位置: 代码迷 >> ASP.NET >> dataGrid模版列中的DropDownList 要实现拼音索引解决方法
  详细解决方案

dataGrid模版列中的DropDownList 要实现拼音索引解决方法

热度:5862   发布时间:2013-02-26 00:00:00.0
dataGrid模版列中的DropDownList 要实现拼音索引
要是在dataGrid模版列中的

------解决方案--------------------------------------------------------
使用arraylist么?还是数据库里面的数据? 如果是数据库的话,那么可以 desc 字段列名排序啊

如果是arraylist可以使用sort方法排序么,详见
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemCollectionsArrayListClassSortTopic.htm
using System;
using System.Collections;

public class SamplesArrayList {

public class myReverserClass : IComparer {

// Calls CaseInsensitiveComparer.Compare with the parameters reversed.
int IComparer.Compare( Object x, Object y ) {
return( (new CaseInsensitiveComparer()).Compare( y, x ) );
}

}

public static void Main() {

// Creates and initializes a new ArrayList.
ArrayList myAL = new ArrayList();
myAL.Add( "The " );
myAL.Add( "QUICK " );
myAL.Add( "BROWN " );
myAL.Add( "FOX " );
myAL.Add( "jumped " );
myAL.Add( "over " );
myAL.Add( "the " );
myAL.Add( "lazy " );
myAL.Add( "dog " );

// Displays the values of the ArrayList.
Console.WriteLine( "The ArrayList initially contains the following values: " );
PrintIndexAndValues( myAL );

// Sorts the values of the ArrayList using the default comparer.
myAL.Sort( 1, 3, null );
Console.WriteLine( "After sorting from index 1 to index 3 with the default comparer: " );
PrintIndexAndValues( myAL );

// Sorts the values of the ArrayList using the reverse case-insensitive comparer.
IComparer myComparer = new myReverserClass();
myAL.Sort( 1, 3, myComparer );
Console.WriteLine( "After sorting from index 1 to index 3 with the reverse case-insensitive comparer: " );
PrintIndexAndValues( myAL );

}

public static void PrintIndexAndValues( IEnumerable myList ) {

int i = 0;
System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();
while ( myEnumerator.MoveNext() )
Console.WriteLine( "\t[{0}]:\t{1} ", i++, myEnumerator.Current );
Console.WriteLine();

}

}


/*
This code produces the following output.
The ArrayList initially contains the following values:
[0]: The
[1]: QUICK
[2]: BROWN
[3]: FOX
[4]: jumped
[5]: over
[6]: the
[7]: lazy
[8]: dog

After sorting from index 1 to index 3 with the default comparer:
[0]: The
[1]: BROWN
[2]: FOX
[3]: QUICK
[4]: jumped
[5]: over
[6]: the
[7]: lazy
[8]: dog

After sorting from index 1 to index 3 with the reverse case-insensitive comparer:
[0]: The
[1]: QUICK
[2]: FOX
[3]: BROWN
[4]: jumped
[5]: over
[6]: the
[7]: lazy
[8]: dog
*/

  相关解决方案