1、查询
<div class="span8">
@using (Ajax.BeginForm("方法", "控制器",
new RouteValueDictionary { { "id", "" } }, new AjaxOptions()
{
HttpMethod = "Get",
UpdateTargetId = "PageDiv",
InsertionMode = InsertionMode.Replace
}, new RouteValueDictionary { { "id", "searchForm" } }))
{
<div class="dataTables_filter">
<label>
<button type="submit" class="btn">搜索 <i class="icon-search"></i></button>
</label>
<label>
<span>名称:</span>
@Html.TextBox("SearchName", null, new { @class = "m-wrap small" })
</label>
<label>
<span>类型:</span>
@Html.DropDownList("SearchCouponType", new SelectListItem[] { new SelectListItem { Text = "全部", Value = "0" }, new SelectListItem { Text = "类型一", Value = "1" }, new SelectListItem { Text = "类型二 ", Value = "2" } })
</label>
</div>
}
</div>
2、分页里添加 DataFormId = "searchForm"
<div id="showPage" class="pages">
@Ajax.Pager(Model, new PagerOptions { PageIndexParameterName = "id", PrevPageText = "上页", NextPageText = "下页", FirstPageText = "首页", LastPageText = "尾页", CssClass = "pagination", CurrentPagerItemTemplate = "<a href=\"#\" class=\"number current\">{0}</a>", DisabledPagerItemTemplate = "<a disabled >{0}</a>", PagerItemTemplate = "{0}" }, new MvcAjaxOptions { UpdateTargetId = "PageDiv", DataFormId = "searchForm" })
<span>总页数:@Model.TotalPageCount</span><span>总条数:@Model.TotalItemCount</span>
</div>