Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller 在重新加载页面时,GridMvc上的分页不起作用_Model View Controller_Paging_Mvcgrid - Fatal编程技术网

Model view controller 在重新加载页面时,GridMvc上的分页不起作用

Model view controller 在重新加载页面时,GridMvc上的分页不起作用,model-view-controller,paging,mvcgrid,Model View Controller,Paging,Mvcgrid,我有两种方法httpget as 公共行动结果MiReport() { 返回视图(); } 和httppost as public ActionResult GetReportView(string startdate,string enddate) { ReportModel Obj = new ReportModel( startdate, enddate ); return PartialView("GetReportView",Obj ); } 我把网格绑定为 @usi

我有两种方法httpget as 公共行动结果MiReport() { 返回视图(); }

和httppost as

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>
@使用GridMvc.Html
报告
@Grid(Model.lstReport).Columns(Columns=>{
columns.Add(c=>c.rep).标题为(“rep”);
columns.Add(c=>c.businessName)。标题为(“企业名称”);
columns.Add(c=>c.contactNmae).标题为(“联系人姓名”);
}).带分页功能(10)
我在视图中显示它加载了前10行,但当我点击分页按钮时,它调用Get方法,页面被重新排序。 请帮帮我。
提前谢谢

您需要为网格命名如下(Index.cshtml):

现在在索引方法中,将其更改为:

 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();
}
希望这有帮助

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();
}