1。将模型从操作传递到视图
public ActionResult Request()
{
List<string> buildType = new List<string>();
BuildRepository bs = new BuildRepository();
buildType = bs.PopulateBuildType();
if (buildType.Count() > 0)
{
ViewBag.BuildType = new SelectList(buildType);
}
List<string> buildMode = new List<string>();
buildMode.Add("Complete");
buildMode.Add("Repack");
ViewBag.BuildMode = new SelectList(buildMode);
BuildModel bsm = new BuildModel();
bsm.BuildStatusData();
return View(bsm);
}
2。将模型从视图传递到部分视图
@{
BuildModel bm = Model as BuildModel;
}
<div id="buildstatus">
@Html.Partial("_BuildStatus", bm)
</div>
第3。能够获取BuildStatus属性(Datasource)的记录。但是没有渲染Grid(第3个属性Grid)。在检查列时收到错误 “base {System.TypeLoadException} = {”找不到入口点。“:”“}”
@{
BuildModel bm = Model as BuildModel;
}
<div id="buildstatus">
@{Html.Grid<BuildStatus>("BuildStatusGrid").Datasource(bm.BuildStatus)
.Column(col =>
{
col.Add(c => c.BuildType).HeaderText("Build Type");
col.Add(c => c.QueuedItems).HeaderText("Queued Time");
col.Add(c => c.LastStartTime).HeaderText("Last Start Time");
}).Render(); }
</div>