Click here to Skip to main content
15,906,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...
Posted
Updated 26-Dec-12 2:03am
v2

C#
AL.ToArray(typeof(Employee)) //where insted of Employee must be your datatype!
 
Share this answer
 
Comments
Oleksandr Kulchytskyi 26-Dec-12 8:15am    
How to print in MVC telerik grid ... hmmm...
public ActionResult Index(){
ArrayList AL = new ArrayList();
DataClasses1DataContext contextData = new DataClasses1DataContext(); System.Data.Linq.ISingleResult 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);
}
ViewBag.Collection= AL.ToArray(typeof(//yourData));
}

and somewhere in your VIEW you must assign ItemSource to ViewBag.Collection
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[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900