C# linq 分頁
protected int getCount()
{
//設定總資料行.
int sum = lqc.Photo_Category.Count();
labPageCount.Text = sum.ToString();
//獲取可以分的頁面
int s1 = sum / pageSize;
//當總行數對頁數求餘後是否大於0,如果大於獲取1否則獲取0
int s2 = sum % pageSize > 0 ? 1 : 0;
//計算出總頁數
int count = s1 + s2;
return count;
}
protected void lnkbtnUp_Click(object sender, EventArgs e)
{
//設定當前頁數為當前頁數減一
ViewState["pageIndex"] = Convert.ToInt32(ViewState["pageIndex"]) - 1;
//呼叫自定義bindGrid方法繫結GridView控制元件
BindGV();
}
protected void lnkbtnDown_Click(object sender, EventArgs e)
{
//設定當前頁數為當前頁數加一
ViewState["pageIndex"] = Convert.ToInt32(ViewState["pageIndex"]) + 1;
//呼叫自定義bindGrid方法繫結GridView控制元件
BindGV();
}
protected void lnkbtnBottom_Click(object sender, EventArgs e)
{
//設定當前頁數為總頁面減一
ViewState["pageIndex"] = getCount() - 1;
//呼叫自定義bindGrid方法繫結GridView控制元件
BindGV();
}