且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MVC4中将ArrayList转换为IEnumerable

更新时间:2023-12-02 16:10:10

AL.ToArray(typeof(Employee)) //where insted of Employee must be your datatype!


不要将ArrayList转换为任何东西。使用要传递到网格的公共属性创建 YourClass ,并在此代码中创建列表< YourClass> ,填写数据,就是这样。但也许存储过程(?)返回正确的类型,因此您可以按原样返回它。

但是由于目前还不清楚整个方法是怎么样的(你只发布了身体:(),我只能猜到你想要的东西。所以请参考官方文档: http://www.telerik.com/help/aspnet -mvc / telerik-ui-components-grid-data-binding-ajax-binding.html [ ^ ]
Don''t convert ArrayList to anything. Create a YourClass with the public properties you want to pas to the grid, and in this code create a List<YourClass>, fill the data in, and that''s it. But perhaps the stored procedure(?) is returning the correct type, thus you can simply return it as it is.
But as it is not clear how the whole method looks like (you posted only the body :( ), I can only guess what you want. So firt of all consult the official documentation: http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-data-binding-ajax-binding.html[^]