我想将列表框中的数据绑定为mvc
中的网格视图@model IEnumerable<ProjectModel>
@{
var grid = new WebGrid(
source: Model,
rowsPerPage: 4);
}
@grid.GetHtml(
tableStyle: "grid",
headerStyle: "header",
rowStyle: "row",
footerStyle: "footer",
alternatingRowStyle: "altRow",
columns: grid.Columns (
grid.Column("projectName"),
grid.Column("ProjectID")
))
就像我们在这个视图中所做的那样。
答案 0 :(得分:0)
对于绑定ListBox,请执行此操作,
@Html.ListBoxFor(m => m.SelectedValues,
Model.SomeSelectionList.Select(person=>
new SelectListItem
{
Text = person.Name,
Value = person.Id,
Selected = // some condition that returns true
}),
new { Multiple = "multiple", size = "4"})