private void MakePager_BigData()
{
try
{
var itemCount = new List<int>();//數(shù)據(jù)源總共多少數(shù)據(jù)的整形鏈表
int pageCount = IDList.Count / dataGridPageSize; //計(jì)算出總共多少頁(yè)
//
for (int i = 0; i < pageCount; i++)
{
itemCount.Add(i);
}
PagedCollectionView pcv = new PagedCollectionView(itemCount);//創(chuàng)建PagedCollectionView
if (pcv != null)
{
pcv.PageSize = 1;//設(shè)置PagedCollectionView的每頁(yè)顯示1條數(shù)據(jù)(虛擬對(duì)應(yīng)的,為了和datagrid對(duì)應(yīng))
dataPager1.PageSize = 1;//設(shè)置dataPager每頁(yè)顯示1條數(shù)據(jù)(虛擬對(duì)應(yīng)的,為了和datagrid對(duì)應(yīng))
this.dataPager1.Source = pcv;//設(shè)置dataPager的數(shù)據(jù)源
}
}
catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); }
}
//根據(jù)頁(yè)索引動(dòng)態(tài)綁定數(shù)據(jù)源
private void dataPager1_PageIndexChanged(object sender, EventArgs e)
{
int curPageIdx = dataPager1.PageIndex;
int skipData = curPageIdx * dataGridPageSize;
List<IDData> curBindingDataSource = ((from p in IDList select p).Skip(skipData).Take(dataGridPageSize)).ToList();
dataGrid1.ItemsSource = curBindingDataSource;
}
posted on 2013-04-15 15:35
天書 閱讀(1304)
評(píng)論(0) 編輯 收藏 引用