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 属性(数据源)的记录。但是,虽然没有呈现 Grid(3rd property Grid)。在检查列时出现错误“base {System.TypeLoadException} = {"Entry point was not found.":""}"
@{
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>