我正在学习ASP.Net MVC; 我正在使用带有MVC4的Visual Studio Express 2012(这是最后一个版本)而且我对这些东西都是全新的.我的目标是将一个巨大的Web应用程序重写为MVC,因此我被告知使用代码优先方法将我的主要解决方案分成3个项目:
我对MVC很熟悉,但没有把东西分成不同的项目.现在我有点失落,我不知道如何做到这一点,这应该参考谁,在哪里,如何,等等.
我正在尝试使用Infragistics的网格来显示我的数据库中的项目列表.我正在使用带有Razor引擎的MVC应用程序中的实体框架的代码优先方法.除了Infragistics网格之外,视图中的每个东西都能正常工作.
这是我的家庭观点:
@using Infragistics.Web.Mvc
@model IEnumerable<BusinessModel.Models.TestPlan>
@{
ViewBag.Title = "Home";
}
@( Html.Infragistics().Grid<BusinessModel.Models.TestPlan>(Model)
.AutoGenerateColumns(true)
.DataSourceUrl(Url.Action("igListTestPlan"))
.DataBind()
.Render())
Run Code Online (Sandbox Code Playgroud)
这是我的控制器:
[GridDataSourceAction]
public ActionResult igListTestPlan()
{
return View(service.getListTestPlan());
}
Run Code Online (Sandbox Code Playgroud)
使用firebug我可以清楚地看到请求是以状态代码"200 OK"发送的,但响应选项卡是空的.它还会导致控制台出错(在infragistics.js中):
Uncaught TypeError: Cannot read property 'length' of undefined
Run Code Online (Sandbox Code Playgroud)
我想这是因为空的反应.
我尝试了什么:
调试我的控制器显示我return View(service.getListTestPlan());没有返回一个空列表:我有3个有效的项目.
我也试过Html.Infragistics().Grid<BusinessModel.Models.TestPlan>(Model__.ToList())但没有改变.还Html.Infragistics().Grid(Model)告诉我我的参数无效
提前致谢.