我有两种方法httpget as
public ActionResult MiReport()
{
return View();
}
httppost 为
public ActionResult GetReportView(string startdate,string enddate) {
ReportModel Obj = new ReportModel( startdate, enddate );
return PartialView("GetReportView",Obj );
}
我将网格绑定为
@using GridMvc.Html
<div class="col-md-12">
<h4><strong>REPORT</strong></h4>
@Html.Grid(Model.lstReport).Columns(columns => {
columns.Add(c => c.rep).Titled("REP");
columns.Add(c => c.businessName).Titled("BUSINESS NAME");
columns.Add(c => c.contactNmae).Titled("CONTACT NAME");
}).WithPaging(10)
</div>
我在查看它的加载前 10 行时显示它很好,但是当我单击分页按钮时,它调用 Get 方法并且页面正在重新加载。
您需要为网格命名,如下所示(Index.cshtml):
.WithPaging(10, 10, "grid1")
现在在 Index 方法中将其更改为:
public ActionResult Index(String grid1 = "")
现在当你点击页面时,你会看到url中的页码为grid1=3,这将被读入Index方法的参数grid1中。
现在在此方法中检查:-
if (!String.IsNullOrEmpty(grid1))
{
//my grid was populated based on PersonnelId selected in some dropdown on the view.You can use the variable in which you stored your key.
id = TempData["TimeOffPersonnelID"].ToString();
}
希望这有帮助!