gridview 手寫分頁

2021-06-22 16:38:01 字數 1383 閱讀 4926

前台  各種按鈕 共

頁, 當前第

頁   共

條記錄, 每頁顯示條    

跳到 onselectedindexchanged="asd_selectedindexchanged" />頁

後台protected void page_load(object sender, eventargs e) }

protected void btnfirst_click1(object sender, eventargs e)

protected void btnprev_click1(object sender, eventargs e)

protected void btnnext_click1(object sender, eventargs e)

protected void btnlast_click1(object sender, eventargs e)

protected void asd_selectedindexchanged(object sender, eventargs e)

//繫結

public void gridviewbind(string page)

else

if (!ispostback) }

//設定分頁資訊的顯示

lblcurrpage.text = currpage.tostring();

lblpagecount.text = pagecount.tostring();

lblpagesize.text = pagesize.tostring();

lbltotalcount.text = totalcount.tostring();

//設定翻頁按鈕的可用性

btnfirst.enabled = btnprev.enabled = btnnext.enabled = btnlast.enabled = true;

if (currpage == 1)

if (currpage == pagecount)

ddlpager.text = currpage.tostring();

//從查詢出的所有記錄中篩選出即將呈現的當前頁的資料集合

int loopcount = (currpage == pagecount) ? totalcount - (currpage - 1) * pagesize : pagesize; //顯示的記錄條數

datarowview drwstobind = new datarowview[loopcount];

for (int i = 0; i < loopcount; i++)

gridview1.datasource = drwstobind;

gridview1.databind();

} }

gridview手寫繫結

using system using system.collections.generic using system.linq using system.web using system.web.ui using system.web.ui.webcontrols using comp.model ...

gridview分頁樣式

在asp.net 2.0種提供了gridview控制項。該控制項的分頁比較方便,可以通過在visual studio net 2005種簡單設定即可實現各種分頁功能。1.預設分頁方式 1 是否允許分頁 gridview的allowpaging屬性。2 每頁記錄數 gridview的 pagesize...

gridview分頁樣式

在asp.net 2.0種提供了gridview控制項。該控制項的分頁比較方便,可以通過在visual studio net 2005種簡單設定即可實現各種分頁功能。1.預設分頁方式 1 是否允許分頁 gridview的allowpaging屬性。2 每頁記錄數 gridview的 pagesize...