我有一个 JSON 函数来返回以下数据,这是我所期望的:
[{"ShowId":1,"Title":"The Forresters Axe","Date":"\/Date(1339714800000)\/","Time":{"Hours":19,"Minutes":0,"Seconds":0,"Milliseconds":0,"Ticks":684000000000,"Days":0,"TotalDays":0.79166666666666663,"TotalHours":19,"TotalMilliseconds":68400000,"TotalMinutes":1140,"TotalSeconds":68400}}]
但是当我尝试在视图页面上显示标题时,我遇到了问题。这是查看页面代码:
<table> @foreach (var showList in Model) {<tr><td>@showList.Title</td></tr>}<.table>
这是我一直在使用的 ActionResult,但是当我进入视图时,我无法获取要显示的数据。我使用上面的 JSON 函数来仔细检查我是否拥有正确的数据并且没有尝试调用不存在的东西。
enter/*-------------------------------------------------------
BOOKING/CHECKAVAIL ACTIONRESULT CALLING CHECKAVAIL VIEW
Select information from Run table where the id == ShowId
------------------------------------------------------*/
public ActionResult CheckAvail(int id)
{
var showList = from r in db.Runs
join s in db.Shows on r.ShowId equals s.ShowId
where r.ShowId == id
select new
{
ShowId = r.ShowId,
Title = s.Title,
Date = r.Date,
Time = r.Time
};
return View(showList);
}
我得到的错误是:
RuntimeBinderException 未被代码处理
“对象”不包含标题的定义