我正在使用nop commercer2.6 所以我想创建自定义报告,我想为该报告做分页。
这是我的功能
public virtual IPagedList<HireItemReportLine> HireItemReport(int ceremony_id, string Fname, string Mname, string Lnmae, string emailAdd, int sesson_id, int pageIndex, int pageSize)
{
var query1 = from opv in _opvRepository.Table
join o in _orderRepository.Table on opv.OrderId equals o.Id
join gr in _graduandRepository.Table on opv.graduand_id equals gr.Id
join pv in _productVariantRepository.Table on opv.ProductVariantId equals pv.Id
join p in _productRepository.Table on pv.ProductId equals p.Id
join c in _ceremonyRepository.Table on gr.ceremony_id equals c.Id
join s in _seasonRepository.Table on c.season_id equals s.Id
where (!o.Deleted) && (opv.IsHireItem == true) &&
(!p.Deleted) &&
(!pv.Deleted)
select new
{
opvTable = opv,
grTable = gr,
seaTable = s,
};
if (!(sesson_id == 0))
query1 = query1.Where(item => item.seaTable.Id == sesson_id);
if (!(ceremony_id == 0))
query1 = query1.Where(item => item.opvTable.ceremony_id == ceremony_id);
if (!String.IsNullOrEmpty(Fname))
query1 = query1.Where(item => item.grTable.first_name == Fname);
if (!String.IsNullOrEmpty(Mname))
query1 = query1.Where(item => item.grTable.middle_name == Mname);
if (!String.IsNullOrEmpty(Lnmae))
query1 = query1.Where(item => item.grTable.last_name == Lnmae);
if (!String.IsNullOrEmpty(emailAdd))
query1 = query1.Where(item => item.grTable.email == emailAdd);
var query2 = from opv in query1
group opv by opv.opvTable.OrderId into g
select new
{
OrderId = g.Key,
TotalAmount = g.Sum(x => x.opvTable.PriceInclTax),
};
int totalCount = query2.Count();
query2 = query2.OrderByDescending(x => x.OrderId);
var result = query2.ToList().Select(x =>
{
return new HireItemReportLine()
{
OrderId = x.OrderId,
Amount= x.TotalAmount,
};
});
var orders_1 = result.ToList();
return new PagedList<HireItemReportLine>(orders_1, pageIndex, pageSize,totalCount);
}
这是PagedLis()函数
public PagedList(IEnumerable<T> source, int pageIndex, int pageSize, int totalCount)
{
TotalCount = totalCount;
TotalPages = TotalCount / pageSize;
if (TotalCount % pageSize > 0)
TotalPages++;
this.PageSize = pageSize;
this.PageIndex = pageIndex;
this.AddRange(source);
}
我想将此数据绑定到网格视图,并且它具有分页功能。我可以绑定并显示页码。但是我的问题是当我在网格视图中单击页面时它始终只显示第一页。 你有什么想法吗?