我使用网络网格来显示员工姓名,以及针对每个员工的下拉列表中的项目。对于项目下拉列,我必须将日期显示为从 HTML 帮助程序返回的列标题。即按照下面的代码而不是列标题“SelectedDate”,我必须显示由 Html 帮助器 (DateTime)@Html.GetNextDate((DateTime)item.SelectedDate, 0)) 返回的值。
下面是视图的快照
@{
var grid = new WebGrid(Model.employeeProjectsMapper);
}
@grid.GetHtml(
columns: grid.Columns(
grid.Column("EmployeeName"),
grid.Column(
header: "SelectedDate",
format:
@<span>
@{ var index = Guid.NewGuid().ToString(); }
@Html.Hidden("employeeProjectsMapper.Index", index)
@Html.Hidden("employeeProjectsMapper[" + index + "].EmployeeID", (Int64)item.EmployeeID)
@Html.Hidden("employeeProjectsMapper[" + index + "].SelectedDate",
(DateTime)@Html.GetNextDate((DateTime)item.SelectedDate, 0))
@Html.DropDownList("employeeProjectsMapper[" + index + "].SelectedProject",
Model.ProjectList)
</span>
)
)
)
任何帮助深表感谢。谢谢苏玛