0

我想将我的数据绑定在列表框中,就像 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")
))

就像我们在这个视图中所做的那样。

4

1 回答 1

0

对于 Binding 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"}) 
于 2013-09-24T10:54:25.163 回答