排序Gridview或IList

时间:2012-07-12 11:37:19

标签: c# asp.net gridview ilist

以下是我只能编辑的代码:

ICCModelController ctrl = ControllerGettersFactory.ModelControllerGetters().CCModelController;
IList list = ctrl.SearchCareersWithCategories(null, 0, DateTime.Today);

CareerGrid.DataSource = list;
CareerGrid.DataBind();

当前“CareerGrid”网格视图以“日期”列的升序排列。 我希望它按降序排列。

1 个答案:

答案 0 :(得分:1)

CareerGrid.DataSource = list.OrderByDescending(x=>x.Date);
CareerGrid.DataBind();

或者,如果它已按日期排序

CareerGrid.DataSource = list.Reverse();
CareerGrid.DataBind();