自定義分頁

2021-05-25 12:10:47 字數 1372 閱讀 3701

前台:

後台:

資料繫結:private void gridview_bind()

sql += " order by c.aid,c.itemid,c.score";

datatable dt = dataaccess.getdatatable(sql);

pageddatasource ps = new pageddatasource();//生成pagedatasource的例項用於分頁

ps.datasource = dt.defaultview;

ps.allowpaging = true;

ps.pagesize = 8;

int currentpage = convert.toint32(label4.text);

ps.currentpageindex = currentpage - 1;

if (ps.pagecount <= 1)

else

if (currentpage == ps.pagecount)

if (currentpage > 1 && currentpage < ps.pagecount)

label5.text = convert.tostring(ps.pagecount);

label6.text = label4.text + "/" + label5.text + "頁";

}this.gridview1.datasource = ps;

this.gridview1.databind();

}事件:

///

/// 首頁

///

///

///

protected void linkbutton2_click(object sender, eventargs e)

///

///

protected void linkbutton3_click(object sender, eventargs e)

///

///

protected void linkbutton4_click(object sender, eventargs e)

///

/// 尾頁

///

///

///

protected void linkbutton5_click(object sender, eventargs e)

初始化:

if (!ispostback)

自定義分頁

分頁 public string madebuttonlink int pagecount,int curpage,string szurl pagecount得到頁數 curpage當前頁 szurl連線位址 public int getpagecount string sztable,int l...

自定義分頁

分頁元件使用示例 1 先取出所有資料user list 2 例項化 obj pagination request.get.get page 1 len user list request 3 對所有資料列表切片 即切出一頁資料 page user list user list obj.start o...

antd自定義分頁器 自定義分頁器例項

def init self,current page num,all count,request,per page num 2,pager count 11 封裝分頁相關資料 param current page num 當前訪問頁的數字 param all count 分頁資料中的資料總條數 pa...