using System.ComponentModel.DataAnnotations;
namespace Zhong.Web.Models
{
[MetadataType(typeof(T_StudentValidateInfo))]
public partial class T_Student
{
}
public class T_StudentValidateInfo
{
[Display(Name="姓名")]
[Required(ErrorMessage ="姓名不能为空")]
[StringLength(10,ErrorMessage ="姓名长度超出限制")]
public string Name { get; set; }
[Display(Name="学号")]
[Required]
[StringLength(20,MinimumLength =10,ErrorMessage ="长度为10-20")]
public string StudentId { get; set; }
}
}
public ActionResult List(int page = 1)
{
//var students = entities.T_Student.OrderBy(s => s.Id).Skip((page - 1) * 2).Take(2);
var students = entities.T_Student.OrderBy(s => s.Id);
return View(students.ToPagedList(page, 2));
}
@using PagedList.Mvc
@model PagedList.IPagedList<Zhong.Web.Models.T_Student>
@{
ViewBag.Title = "List";
}
<h2>List</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
姓名
</th>
<th>
学号
</th>
<th>
专业
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.StudentId)
</td>
<td>
@Html.DisplayFor(modelItem => item.T_Major.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
</table>
@Html.PagedListPager(Model,page => Url.Action("List",new { page}))
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有