DataGrid分頁控制項

2021-03-31 08:56:57 字數 2942 閱讀 2055

imports

system.data.sqlclient

imports

system.data

imports

system.web.ui

public

class ucdatagridpaging

inherits system.web.ui.usercontrol

protected

withevents btnfirst as system.web.ui.webcontrols.linkbutton

protected

withevents btnprev as system.web.ui.webcontrols.linkbutton

protected

withevents btnnext as system.web.ui.webcontrols.linkbutton

protected

withevents btnlast as system.web.ui.webcontrols.linkbutton

protected

withevents lblcurrentindex as system.web.ui.webcontrols.label

protected

withevents lblpagecount as system.web.ui.webcontrols.label

#region " web form designer generated code "

'this call is required by the web form designer.

private

sub initialize***ponent()

end

sub

private

sub page_init(byval sender as system.object, byval e as system.eventargs) handles

mybase.init

'codegen: this method call is required by the web form designer

'do not modify it using the code editor.

initialize***ponent()

endsub

#end

region

protected

withevents uc_datagrid as system.web.ui.webcontrols.datagrid

public

writeonly

property datagridname() as datagrid

set(byval value as datagrid)

uc_datagrid = value

endset

end

property

private

sub page_load(byval sender as system.object, byval e as system.eventargs) handles

mybase.load

btnfirst.text = "

最首?"

btnprev.text = "

前一?"

btnnext.text = "

下一?"

btnlast.text = "

最後?"

showstats()

endsub

sub pagerbuttonclick(byval sender as

object, byval e as eventargs)

'used by external paging ui

dim arg as

string = sender.***mandargument

select

case arg

case "next"

if (uc_datagrid.currentpageindex < (uc_datagrid.pagecount - 1)) then

uc_datagrid.currentpageindex += 1

endif

case "prev"

if (uc_datagrid.currentpageindex > 0) then

uc_datagrid.currentpageindex -= 1

endif

case "last"

uc_datagrid.currentpageindex = (uc_datagrid.pagecount - 1)

case

else

'page number

uc_datagrid.currentpageindex = system.convert.toint32(arg)

endselect

bindgrid()

showstats()

endsub

sub bindgrid()

uc_datagrid.databind()

showstats()

end

sub

sub showstats()

lblcurrentindex.text = "

第" + (uc_datagrid.currentpageindex + 1).tostring() + " ?"

lblpagecount.text = "?

共" + uc_datagrid.pagecount.tostring() + " ?"

end

sub

endclass

修改DataGrid控制項的預設的分頁樣式

其實也不是很難,先看看datagrid顯示的是什麼東東,這樣可能會有點眉目。在datagrid中,分頁導航欄是用一行 tablerow 來表現出來,在這個行 tablerow 中,只有乙個列 tablecell 我們所看到的所有的數字超連結按鈕 linkburron 都是這個列 tablecell ...

datagrid後端分頁

int pagenum integer.parseint request.getparameter page int rows integer.parseint request.getparameter rows 獲取前端datagrid傳過來的頁碼和每頁行數。資料庫操作分為兩個 選取所有記錄res...

DataGrid控制項用法詳解

寫在前面 在網格控制項中顯示查詢的資料結果。對網格控制項的顯示進行控制 如列寬 對網格內容格式進行控制 如將小於 的小數顯示成百分數 二 準備工作 先建立乙個工程,我的主框架選用對話方塊,然後插入你datagrid控制項,見如圖 圖 找到microsoft datagrid oledb 6.0 控制...