Controller函数
public ActionResult Index()
{
var user = new SysUsers();
TryUpdateModel(user);
return View(user);
}
View页面
@model lktec.am7.Entity.SysUsers
@{ViewBag.Title = "系统用户管理";}
<h2>@ViewBag.Title</h2>
<div class="inner">
<p>@Html.ActionLink("注册新用户", "Register")</p>
@using(Html.BeginForm("Index","Account",FormMethod.Get))
{
<table>
<tr>
<td class="lbltitle">用户名/姓名</td>
<td>@Html.TextBoxFor(m=>m.UID)</td>
<td class="lbltitle">电话/手机</td>
<td>@Html.TextBoxFor(m => m.Phone)</td>
</tr>
<tr>
<td class="lbltitle">邮件</td>
<td>@Html.TextBoxFor(m => m.Email)</td>
<td class="lbltitle">部门</td>
<td>@Html.TextBoxFor(m => m.Department)</td>
</tr>
<tr>
<td class="lbltitle">状态</td>
<td>@Html.DropDownListFor(m => m.Status,Model.GetStatusSIL())</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="查找"/></td>
</tr>
</table>
}
<table>
<tr>
<th>@Html.ActionLink("编号", "Index", Model.RouteData("OrderBy", Model.NextOrderBy("ID")),new Dictionary<string,object>{ { "class","cls_"+Model.OrderByStatus("ID")}})</th>
<th>@Html.ActionLink("用户名", "Index", Model.RouteData("OrderBy", Model.NextOrderBy("UID")), new Dictionary<string,object>{ { "class", "cls_" + Model.OrderByStatus("UID") }})</th>
<th>@Html.ActionLink("姓名", "Index", Model.RouteData("OrderBy", Model.NextOrderBy("NickName")), new Dictionary<string,object>{ { "class", "cls_" + Model.OrderByStatus("NickName") }})</th>
<th>邮件</th>
<th>部门</th>
<th>电话</th>
<th>手机</th>
<th>用户状态</th>
<th>操作</th>
</tr>
@foreach (var item in Model.Items)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.ID) </td>
<td>@Html.DisplayFor(modelItem => item.UID) </td>
<td>@Html.DisplayFor(modelItem => item.NickName) </td>
<td>@Html.DisplayFor(modelItem => item.Email) </td>
<td>@Html.DisplayFor(modelItem => item.Department) </td>
<td>@Html.DisplayFor(modelItem => item.Telephone) </td>
<td>@Html.DisplayFor(modelItem => item.Mobile) </td>
<td>@lktec.am7.Util.EnumFunc.GetCommonStatusName(item.Status) </td>
<td>
@Html.ActionLink("编辑", "Edit", new { id = item.ID })
@Html.ActionLink("设置角色", "Roles", new { id = item.ID })
@Html.ActionLink("查看", "Details", new { id = item.ID })
</td>
</tr>
}
</table>
@for (var p = 0; p < Model.PageCount; p++)
{
if (p == Model.CurrentPageIndex)
{
<span>@(p + 1)</span>
}
else
{
@Html.ActionLink("第" + (p + 1) + "页", "Index", Model.RouteData("CurrentPageIndex", p));
}
}
</div>