简体   繁体   中英

How to Display DataTables in a View when using ASP.NET MVC?

I have an Action as below which returns a dataset to a partial view:

public ActionResult DataSet(int id)
{

DataSet dataSet = Model.CreateDataSet(id);

return PartialView(dataSet);

}

and I'm using it like this in my main view:

@{Html.RenderAction("DataSet", new {id= 1});}

I'd like to show the contents of the DataSet on my Razor Partial View. For example, if my dataset has 2 datatables, I'd like to display 2 Grid Tables with the columns and rows.

I realized that MVC doesn't have any GridView control like WebForms.

How would that be possible in MVC?

Thanks

You have two options, use a premade grid (the one in MVCContrib is really good and what i use) or manually format the table yourself (nested foreaches will do this just fine)

Also using either of these methods there's no real need to pull the table out into a separate view (unless you have other reasons for it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM