@model
IEnumerable< 程序集.Models.Student>
@{
var
grid = new
WebGrid(source: Model, rowsPerPage: 2, canPage: true,
canSort: true);
}
@grid.GetHtml(
columns:
grid.Columns
(
grid.Column("StudentId",
"学生编号",
style: "mynameStyle"),
grid.Column("StudentName",
"学生姓名",
style: "mynameStyle"),
grid.Column("StudentAge",
"学生年龄",
style: "mynameStyle"),
grid.Column("StudentSex",
"学生性别",
style: "mynameStyle"),
grid.Column("Grade.GradeName",
"学生班级",
style: "mynameStyle"),
grid.Column("",
"",
format: @<text> @Html.ActionLink("编辑",
"Edit",
new
{ Id = item.StudentId })|
@Html.ActionLink("详细",
"Details",
new
{ id = item.StudentId })|
@Html.ActionLink("删除",
"Delete",
new
{ id = item.StudentId })</text>)
),
tableStyle: "grid",
headerStyle: "headerStyle1",
selectedRowStyle: "selectedRowStyle",
displayHeader:
!IsPost,
fillEmptyRows:
!IsPost, emptyRowCellValue: "这行没东西",
mode:
WebGridPagerModes.All, firstText: "第一页",
previousText:
"上一页",
nextText: "下一页",
lastText: "最后一页",
numericLinksCount:
15
)
<p>总页数:@grid.PageCount
| 每页:@grid.RowsPerPage 行 | 当前第:@(grid.PageIndex+1) 页</p>