C# jqGrid中缺少显示数据

C# jqGrid中缺少显示数据,c#,jquery,asp.net-mvc-3,jqgrid,C#,Jquery,Asp.net Mvc 3,Jqgrid,正如你在下面看到的,我有3张照片(每页5、10和20个数据)。我不知道为什么每页10和20中缺少图片提供的数据 代码 public JsonResult GetDPS(string sidx, string sord, int page, int rows, string startdate, string enddate, string EmployeeId, string month, string year, int ClassificationId) { var

正如你在下面看到的,我有3张照片<代码>(每页5、10和20个数据)。我不知道为什么每页
10和20
中缺少图片提供的数据

代码

public JsonResult GetDPS(string sidx, string sord, int page, int rows, string startdate, string enddate, string EmployeeId, string month, string year, int ClassificationId)
    {
        var context = new Entities();
        var _pr = new Repository();
        int _month = Convert.ToInt32(month);
        int _employeeid = Convert.ToInt32(EmployeeId);
        int _year = Convert.ToInt32(year);
        if (_month > 0 && _year > 0)
        {
            DateTime Dstartdate = new DateTime(_year, _month, 1);
            startdate = Dstartdate.AddDays(-1).ToShortDateString();
            enddate = Dstartdate.AddMonths(1).ToShortDateString();
        }
        int pageIndex = Convert.ToInt32(page) - 1;
        int pageSize = rows;
        var periods = _pr.GetDPSList(Convert.ToDateTime(startdate), Convert.ToDateTime(enddate), _employeeid, ClassificationId);
        int totalRecords = periods.Count();
        int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
        var reqs = periods.OrderBy("it." + sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize);
        int i = 0;
        var rowsObj = new object[pageSize > totalRecords ? totalRecords : pageSize];
        foreach (vwDPSPerEmployee req in reqs)
        {
            int rowId = i;
            int DPSHeaderId = Convert.ToInt32(req.DPSHeaderId);
            string DateApplied = req.DateApplied.Value.ToShortDateString();
            string DPSClassification = req.DPSClassificationDesc;
            string StartDate = req.DateFrom.Value.ToShortDateString();
            string EndDate = req.DateTo.Value.ToShortDateString();
            string Departure = req.Departure.Value.ToShortTimeString();
            string Arrival = req.Arrival.Value.ToShortTimeString();
            string Destination = req.Destination;
            string ContactPerson = req.ContactPerson;
            string Purpose = req.Purpose;
            rowsObj[i] = new { id = i, cell = new object[] { rowId, DPSHeaderId, DateApplied, DPSClassification, StartDate, EndDate, DateofDPS, Departure, Arrival, Destination, ContactPerson, Purpose } };
            i++;
        }
        if (totalRecords != 0)
        {
            for (int j = 0; j < rowsObj.Length; j++)
            {
                if (rowsObj[j] == null)
                { rowsObj[j] = new { id = j, cell = new object[] { j, j, "", "" } }; }
                else { }
            }
        }
        var result = new JsonResult();
        result.Data = new
        {
            total = totalPages,
            page = page,
            records = totalRecords,
            rows = rowsObj
        };
        return result;
    }
public JsonResult GetDPS(string sidx、string sord、int page、int行、string startdate、string enddate、string EmployeeId、string month、string year、int ClassificationId)
{
var context=新实体();
var_pr=新存储库();
int _month=转换为32(月);
int_employeeid=转换为32(employeeid);
int _year=转换为NT32(年);
如果(_月>0和&u年>0)
{
DateTime Dstartdate=新的日期时间(_年,_月,1);
startdate=Dstartdate.AddDays(-1).ToSortDateString();
enddate=Dstartdate.AddMonths(1.ToSortDateString();
}
int pageIndex=Convert.ToInt32(第页)-1;
int pageSize=行;
变量期间=_pr.GetDPSList(Convert.ToDateTime(startdate),Convert.ToDateTime(enddate),_employeeid,ClassificationId);
int totalRecords=periods.Count();
int totalPages=(int)数学上限((float)totalRecords/(float)pageSize);
var reqs=periods.OrderBy(“it.+sidx+”“+sord”).Skip(页面索引*页面大小)。Take(页面大小);
int i=0;
var rowsObj=新对象[pageSize>totalRecords?totalRecords:pageSize];
foreach(vwDPSPerEmployee需求中的需求)
{
int rowId=i;
int-DPSHeaderId=Convert.ToInt32(请求DPSHeaderId);
string DateApplied=req.DateApplied.Value.ToSortDateString();
字符串DPSClassification=req.DPSClassificationDesc;
string StartDate=req.DateFrom.Value.ToSortDateString();
string EndDate=req.DateTo.Value.ToShortDateString();
字符串离开=请求离开值ToShortTimeString();
字符串Arrival=req.Arrival.Value.ToShortTimeString();
字符串目的地=请求目的地;
字符串ContactPerson=req.ContactPerson;
字符串用途=请求用途;
rowsObj[i]=new{id=i,cell=new object[]{rowId,DPSHeaderId,dateapplicated,dpsclassion,StartDate,EndDate,DateofDPS,出发,到达,目的,联系人,目的};
i++;
}
如果(totalRecords!=0)
{
对于(int j=0;j

有人遇到过这样的情况吗?。或者有人知道吗?。我花了几天时间来解决这个问题。

我认为您应该使用Fileddate(dateapplicated)列上的排序

public JsonResult GetDPS(string sidx、string sord、int page、int行、string startdate、string enddate、string EmployeeId、string month、string year、int ClassificationId)
{
var context=新实体();
var_pr=新存储库();
int _month=转换为32(月);
int_employeeid=转换为32(employeeid);
int _year=转换为NT32(年);
如果(_月>0和&u年>0)
{
DateTime Dstartdate=新的日期时间(_年,_月,1);
startdate=Dstartdate.AddDays(-1).ToSortDateString();
enddate=Dstartdate.AddMonths(1.ToSortDateString();
}
int pageIndex=Convert.ToInt32(第页)-1;
int pageSize=行;
变量期间=_pr.GetDPSList(Convert.ToDateTime(startdate),Convert.ToDateTime(enddate),_employeeid,ClassificationId);
int totalRecords=periods.Count();
int totalPages=(int)数学上限((float)totalRecords/(float)pageSize);
var reqs=期间.OrderBy(x=>x.dateapplicated).Skip(pageIndex*pageSize).Take(pageSize);
int i=0;
var rowsObj=新对象[pageSize>totalRecords?totalRecords:pageSize];
foreach(vwDPSPerEmployee需求中的需求)
{
int rowId=i;
int-DPSHeaderId=Convert.ToInt32(请求DPSHeaderId);
string DateApplied=req.DateApplied.Value.ToSortDateString();
字符串DPSClassification=req.DPSClassificationDesc;
string StartDate=req.DateFrom.Value.ToSortDateString();
string EndDate=req.DateTo.Value.ToShortDateString();
字符串离开=请求离开值ToShortTimeString();
字符串Arrival=req.Arrival.Value.ToShortTimeString();
字符串目的地=请求目的地;
字符串ContactPerson=req.ContactPerson;
字符串用途=请求用途;
rowsObj[i]=new{id=i,cell=new object[]{rowId,DPSHeaderId,dateapplicated,dpsclassion,StartDate,EndDate,DateofDPS,出发,到达,目的,联系人,目的};
i++;
}
如果(totalRecords!=0)
{
对于(int j=0;j
谢谢您的评论。但我已经测试过了。正如我调试它时注意到的。当我没有使用断点时,数据被另一个数据替换。您可以看到
8/18/16
。但是我设置了断点
public JsonResult GetDPS(string sidx, string sord, int page, int rows, string startdate, string enddate, string EmployeeId, string month, string year, int ClassificationId)
    {
        var context = new Entities();
        var _pr = new Repository();
        int _month = Convert.ToInt32(month);
        int _employeeid = Convert.ToInt32(EmployeeId);
        int _year = Convert.ToInt32(year);
        if (_month > 0 && _year > 0)
        {
            DateTime Dstartdate = new DateTime(_year, _month, 1);
            startdate = Dstartdate.AddDays(-1).ToShortDateString();
            enddate = Dstartdate.AddMonths(1).ToShortDateString();
        }
        int pageIndex = Convert.ToInt32(page) - 1;
        int pageSize = rows;
        var periods = _pr.GetDPSList(Convert.ToDateTime(startdate), Convert.ToDateTime(enddate), _employeeid, ClassificationId);
        int totalRecords = periods.Count();
        int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
        var reqs = periods.OrderBy(x=>x.DateApplied).Skip(pageIndex * pageSize).Take(pageSize);
        int i = 0;
        var rowsObj = new object[pageSize > totalRecords ? totalRecords : pageSize];
        foreach (vwDPSPerEmployee req in reqs)
        {
            int rowId = i;
            int DPSHeaderId = Convert.ToInt32(req.DPSHeaderId);
            string DateApplied = req.DateApplied.Value.ToShortDateString();
            string DPSClassification = req.DPSClassificationDesc;
            string StartDate = req.DateFrom.Value.ToShortDateString();
            string EndDate = req.DateTo.Value.ToShortDateString();
            string Departure = req.Departure.Value.ToShortTimeString();
            string Arrival = req.Arrival.Value.ToShortTimeString();
            string Destination = req.Destination;
            string ContactPerson = req.ContactPerson;
            string Purpose = req.Purpose;
            rowsObj[i] = new { id = i, cell = new object[] { rowId, DPSHeaderId, DateApplied, DPSClassification, StartDate, EndDate, DateofDPS, Departure, Arrival, Destination, ContactPerson, Purpose } };
            i++;
        }
        if (totalRecords != 0)
        {
            for (int j = 0; j < rowsObj.Length; j++)
            {
                if (rowsObj[j] == null)
                { rowsObj[j] = new { id = j, cell = new object[] { j, j, "", "" } }; }
                else { }
            }
        }
        var result = new JsonResult();
        result.Data = new
        {
            total = totalPages,
            page = page,
            records = totalRecords,
            rows = rowsObj
        };
        return result;
    }