如何在MVC4中将ArrayList转换为IEnumerable [英] how to convert an ArrayList to IEnumerable in MVC4

查看:76
本文介绍了如何在MVC4中将ArrayList转换为IEnumerable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉以下代码的解决方案,我试图将Arraylist转换为IEnumerable ......我希望将该列表转换为MVC telerik网格..



代码:



ArrayList AL = new ArrayList();

DataClasses1DataContext contextData = new DataClasses1DataContext(); System.Data.Linq.ISingleResult< usp_delbithdays_select_birthdate_for_30_daysresult>结果= contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();

var qur = contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();

foreach(var sp in qur)

{

AL.Add(sp);

}

返回AL;





在此先感谢...

Can anyone tell solution to the below code where i am trying to convert Arraylist to IEnumerable...and I want to get that list into MVC telerik grid..

code:

ArrayList AL = new ArrayList();
DataClasses1DataContext contextData = new DataClasses1DataContext(); System.Data.Linq.ISingleResult<usp_delbithdays_select_birthdate_for_30_daysresult> Results = contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();
var qur = contextData.usp_DelBithdays_SELECT_BIRTHDATE_For_30_Days();
foreach (var sp in qur)
{
AL.Add(sp);
}
return AL;


Thanks in advance...

推荐答案

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[^]


这篇关于如何在MVC4中将ArrayList转换为IEnumerable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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