我有多個網格我想提出只在主頁上,但是當我在查看返回多於一個,就說明我的錯誤。MVC如何爲主頁上有多個網格返回查看?
它說我可以嘗試拋出新的異常,但仍然是一個錯誤。我如何讓它顯示多個網格?網格在模型的列表中創建。
@using GridMvc.Html;
@model IEnumerable<Website.Models.Activities>
@model IEnumerable<Website.Models.Cities>
@{
ViewBag.Title = "Index";
}
<head>
<link href="@Url.Content("~/Content/Homestyle.css")" rel="stylesheet" type="text/css" />
</head>
<body>
<h1 align="center" id="homewords">Home</h1><br/><br/><br/>
<p id="mainp" align="center">
Welcome to What2Do, we are a website to help you find things to do around town as a local or a tourist. We are a brand new website
and we are still looking for more places and cities in the future. If you have any good ideas or know good places, please see the about
page to email this information! Hope you enjoy! :)
</p>
<br /><br />
<div id="city">
<p id="choosecity">City: </p>
@Html.Grid(Model).Columns(cols =>
{
cols.Add(c => c.stpete).Titled("St. Petersburg");
cols.Add(c => c.tampa).Titled("Tampa");
cols.Add(c => c.orlando).Titled("Orlando");
});
</div>
<div id="act" align="center">
<p id="activity">Activity: </p>
<select id="ddlactivity" name="activity" size="4">
<option value="1">Theme Parks</option>
<option value="2">Outdoor Activities</option>
<option value="3">Beach Activities</option>
<option value="4">Bars and Music</option>
</select>
</div>
<br/><br/><br/><br/>
<div id="results" width="500px">
@Html.Grid(Model).Columns(columns=>
{
columns.Add(c => c.activity).Titled("Activity");
columns.Add(c => c.location).Titled("Location");
columns.Add(c => c.cost).Titled("Cost");
columns.Add(c => c.hours).Titled("Hours");
}).WithPaging(3).Sortable(true)
</div>
控制器:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Website.Models;
namespace Website.Controllers
{
public class HomeController : Controller
{
// GET: Default
public ActionResult Index()
{
var citymodel = new Cities();
List<Cities> citygrid = citymodel.city();
var model = new Activities();
List<Activities> actgrid = model.Acts();
return View(actgrid, citygrid);
}
使用爲每一集的性能視圖模型 –