关闭

.Net MVC 分页排序查询综合 - Controller+View

250人阅读 评论(0) 收藏 举报

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>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</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)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.UID)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.NickName)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.Email)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.Department)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.Telephone)&nbsp;</td>
        <td>@Html.DisplayFor(modelItem => item.Mobile)&nbsp;</td>
        <td>@lktec.am7.Util.EnumFunc.GetCommonStatusName(item.Status)&nbsp;</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>

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2107次
    • 积分:51
    • 等级:
    • 排名:千里之外
    • 原创:3篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档