其他分享
首页 > 其他分享> > WinForm DataGridView以List为数据源,实现分页查询功能

WinForm DataGridView以List为数据源,实现分页查询功能

作者:互联网

public override List<ModelParent> GetList(int pageIndex, int pageLength, string keyword, int id, ref int DataCount)
{
DataList = Code.BLLInterface.GetList(new Model_ProgramRequest(), FilePath, new Model_ProgramRequest().ClassName);
DataCount = DataList.Count;
List<ModelParent> result = new List<ModelParent>();
List<Model_ProgramRequest> list = DataList.FindAll(x => x.ProgramNo.Contains(keyword) && x.Status != 3);
list.Sort((a,b)=>a.RequestID.CompareTo(b.RequestID));

//通过list的Skip方法和Take方法进行分页查询。 pageIndex:第几页,pageLength:每页长度
var skip = (pageIndex - 1) * pageLength;
foreach (Model_ProgramRequest ProgramRequest in list.Skip(skip).Take(pageLength))
{
result.Add(ProgramRequest);
}
return result;
}

标签:int,数据源,pageLength,List,DataGridView,list,result,ProgramRequest
来源: https://www.cnblogs.com/KevinSteven/p/15945782.html