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

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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值