views:

48

answers:

2

I am long familiar with using the ASP.net GridView in ASP.net forms to display the contents of DataSet on a web page.

What is the best practice for displaying the contents of the DataSet in ASP.net MVC? I can add the DataSet to my DataVew dictionary in my controller, but I'm unsure of how to display it in the View page.

+1  A: 

You may want to view my answer here. If you still have questions I'll be glad to do what I can.

andymeadows
As I mentioned, I added the DataSet to the DataView dictionary in the controller. I just don't know how to display the data in a table aside from just doing a Response.Write("<table>...")
Rice Flour Cookies
If you're looking for server controls you won't find them. You can use css and a combination of UL/OL/LI items to layout your information or you could, as you stated, use tables. If you're looking for something to databind to though, you're out of luck.
andymeadows
A: 

DataSets are uncommon for ASP.NET MVC applications. There are no server side controls that will allow you to display the contents of a DataSet as the GridView control in WebForms. So if you are looking for a best practice, I would suggest you put in place some server side processing that will convert your DataSet into an hierarchy of .NET objects that you would pass to a strongly typed view. Of course if this is a new application you wouldn't even bother fetching the data in a DataSet form but you would use an ORM that will directly give you .NET objects.

So once you have the objects you could take a look at the MVCContrib Grid helper. Of course as you are using ASP.NET MVC 1.0 you will have to make sure to download the proper version of MVCContrib which is compiled against it because the current version is compiled against ASP.NET MVC 2.0.

Darin Dimitrov
OK then. My application must display some tabular data from a SQL server. What is the best practice to do that?
Rice Flour Cookies
I would recommend you reading one of the hundreds of tutorials out there: http://www.asp.net/mvc/tutorials/creating-model-classes-with-the-entity-framework-cs
Darin Dimitrov