How do I use Datatable instead of Entity framework in Asp.Net mvc?
I’m referring to this tutorial on the asp.net Website ….
http://www.asp.net/Learn/mvc/tutorial-21-cs.aspx
….Can I return a datatable instead of a movie or movielist object??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can return whatever you want provided it can be stored (serialized) in the ViewData. There is nothing “magic” about ASP.NET MVC that constrains values and/or types.
If you want to iterate over the DataTable in the view, put it in ViewData in the controller, retrieve it in the View, and iterate over it as you would anywhere else.
DataTable is serializable.
So something similar to the following should work: