Asp.net:与GridView和ObjectDataSource控件排序 [英] Asp.net: Sorting with gridview and objectDataSource

查看:83
本文介绍了Asp.net:与GridView和ObjectDataSource控件排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么做一个排序在GridView与一个ObjectDataSource控件绑定的数据?

how I do a sorting in a gridView with data bound by a ObjectDataSource?

推荐答案

<一个href=\"http://stackoverflow.com/questions/1003037/how-to-sort-using-gridview-and-objectdatasource\">Here是一个已经previously回答的问题。

Here is a question that has been previously answered.

有关实际的排序,你会打电话

For the actual sorting, you would call

collectionOfObjects.OrderBy(x => x.PropertyToSortOn);

您可以使用一个开关来改变基于什么被传递到通过ARGS方法进行排序的。所以它看起来多了几分像这样

You could use a switch to change what to sort on based on what is passed into the method via the args. So it would look a little more like this

switch(propertyName)
{
  case "property1":
    collectionOfObjects.OrderBy(x => x.PropertyToSortOn);
    break;
  case "property2":
    collectionOfObjects.OrderBy(x => x.OtherPropertyToSortOn);
    break;

  ...

}

希望这有助于! :)

Hope this helps! :)

这篇关于Asp.net:与GridView和ObjectDataSource控件排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆