使用前端集合时,“数据源不支持服务器端数据分页”

时间:2022-03-22 15:50:31

I currently have a repeater whose datasource is a List where ModelObject is a custom class in the front-end used to help render the more complex LINQ to SQL object. For example, it renders URLS for links, names of statuses, etc.. The status names are not in the database because we knew we'd have to localize this app someday.

我目前有一个转发器,其数据源是一个List,其中ModelObject是前端的自定义类,用于帮助呈现更复杂的LINQ to SQL对象。例如,它为链接,状态名称等呈现URL。状态名称不在数据库中,因为我们知道有一天我们必须本地化这个应用程序。

Now I need to page and sort this list so I'm trying to switch to a gridview to take advantage of the out of the box functionality. I get the error "The data source does not support server-side data paging". What kind of datasource can I use that will still allow my front-end to customize the output? This seems it should be a common task because apps that are localized need the sort values coming out of the resx files.

现在我需要对此列表进行分页和排序,以便我尝试切换到gridview以利用开箱即用的功能。我收到错误“数据源不支持服务器端数据分页”。我可以使用哪种数据源仍然允许我的前端自定义输出?这似乎应该是一项常见任务,因为本地化的应用程序需要来自resx文件的排序值。

Thanks for your help.

谢谢你的帮助。

2 个解决方案

#1


8  

You can't use an IQueryable object to data bind to a GridView and still use Paging and Sorting. You must return a List to the GridView using the ToList() method.

您不能使用IQueryable对象将数据绑定到GridView,仍然使用分页和排序。您必须使用ToList()方法将List返回给GridView。

See this DevToolShed Article for more information:
http://www.devtoolshed.com/content/gridview-objectdatasource-linq-paging-and-sorting

有关更多信息,请参阅此DevToolShed文章:http://www.devtoolshed.com/content/gridview-objectdatasource-linq-paging-and-sorting

#2


3  

For those that are getting this error but implementing:

对于那些收到此错误但执行的人:

IEnumerable<T> or 
IEnumerable or 
IList<T> or 
IDictionary<T1, T2>.

You need to implement ICollection (the non-generic one) for you to get passed the "The data source does not support server-side data paging" error.

您需要实现ICollection(非泛型的)才能通过“数据源不支持服务器端数据分页”错误。

#1


8  

You can't use an IQueryable object to data bind to a GridView and still use Paging and Sorting. You must return a List to the GridView using the ToList() method.

您不能使用IQueryable对象将数据绑定到GridView,仍然使用分页和排序。您必须使用ToList()方法将List返回给GridView。

See this DevToolShed Article for more information:
http://www.devtoolshed.com/content/gridview-objectdatasource-linq-paging-and-sorting

有关更多信息,请参阅此DevToolShed文章:http://www.devtoolshed.com/content/gridview-objectdatasource-linq-paging-and-sorting

#2


3  

For those that are getting this error but implementing:

对于那些收到此错误但执行的人:

IEnumerable<T> or 
IEnumerable or 
IList<T> or 
IDictionary<T1, T2>.

You need to implement ICollection (the non-generic one) for you to get passed the "The data source does not support server-side data paging" error.

您需要实现ICollection(非泛型的)才能通过“数据源不支持服务器端数据分页”错误。