imports system imports system.data imports system.drawing imports system.text imports system.web imports system.web.ui.webcontrols imports system.web.ui.htmlcontrols public delegate sub binddatadelegate() public class datagridpage
inherits system.web.ui.usercontrol
#region " web フォーム デザイナで生成されたコード "
'この呼び出しは web フォーム デザイナで必要です。 <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
end sub
public binddata1 as binddatadelegate private _dg as datagrid private _autohidden as boolean = true private _pagesize as integer = 10 private _itemcount as integer = 0 private _dispstyle as integer = 1 protected withevents labelmsg as system.web.ui.webcontrols.label protected withevents btnnavfirst as system.web.ui.webcontrols.button protected withevents btnnavprevious as system.web.ui.webcontrols.button protected withevents btnnavnext as system.web.ui.webcontrols.button protected withevents btnnavlast as system.web.ui.webcontrols.button protected withevents tbpage as system.web.ui.webcontrols.textbox protected withevents labelmsg2 as system.web.ui.webcontrols.label protected withevents btnnavgo as system.web.ui.webcontrols.button protected withevents divpanel as system.web.ui.webcontrols.panel protected withevents hdrowcount as system.web.ui.htmlcontrols.htmlinputhidden protected withevents hdcurrentindex as system.web.ui.htmlcontrols.htmlinputhidden
'メモ : 次のプレースホルダ宣言は web フォーム デザイナで必要です。 '削除および移動しないでください。 private designerplaceholderdeclaration as system.object
private sub page_init(byval sender as system.object, byval e as system.eventargs) handles mybase.init ' codegen: このメソッド呼び出しは web フォーム デザイナで必要です。 ' コード エディタを使って変更しないでください。 initializecomponent() addhandler me.load, addressof page_load
end sub
#end region
public property target() as datagrid
get return _dg end get set(byval value as datagrid) _dg = value end set end property public property autohidden() as boolean
get return _autohidden end get set(byval value as boolean) _autohidden = value end set end property
public property pagesize() as integer
get return _pagesize end get set(byval value as integer) _pagesize = value end set end property public property itemcount() as integer
get return _itemcount end get set(byval value as integer) _itemcount = value end set end property
private sub page_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load ' ページを初期化するユーザー コードをここに挿入します。
end sub public sub settarget(byval adg as datagrid, byref abinddata1 as binddatadelegate)
_dg = adg
binddata1 = abinddata1
addhandler btnnavfirst.click, addressof navigationbuttonclick addhandler btnnavprevious.click, addressof navigationbuttonclick addhandler btnnavnext.click, addressof navigationbuttonclick addhandler btnnavlast.click, addressof navigationbuttonclick addhandler btnnavgo.click, addressof navigationbuttonclick addhandler _dg.databinding, addressof zxdatabinding binddata1() end sub public sub setstyle(byval apagesize as integer, byval aautohidden as boolean, byval adispstyle as integer)
divpanel.visible = not aautohidden end sub public sub setstyle(byval apagesize as integer, byval aautohidden as boolean) setstyle(apagesize, aautohidden, 1) end sub public sub setstyle(byval apagesize as integer) setstyle(apagesize, true) end sub public sub navigationbuttonclick(byval sender as object, byval e as system.eventargs) dim direction as string direction = sender.commandname
select case (direction.toupper())
case ("first") _dg.currentpageindex = 0
case ("previous") _dg.currentpageindex = math.max(_dg.currentpageindex - 1, 0)
case ("next") _dg.currentpageindex = math.min(_dg.currentpageindex + 1, _dg.pagecount - 1)
case ("last") _dg.currentpageindex = math.max(_dg.pagecount - 1, 0)
case ("go") try _dg.currentpageindex = math.min(_dg.pagecount - 1, cint(tbpage.text) - 1) tbpage.text = "" catch tbpage.text = "" end try
end select
binddata1()
end sub public sub zxdatabinding(byval sender as object, byval e as system.eventargs)
dim newcount as integer = 0 dim pagecount as integer = 0
if (_dg.datasource is "null") then
setbuttonstate(0) exit sub end if if (_dg.datasource.gettype().tostring().tolower() = "system.data.datatable") then
newcount = _dg.datasource.rows.count
elseif (_dg.datasource.gettype().tostring().tolower() = "system.data.dataview") then
newcount = _dg.datasource.count
elseif (_dg.datasource.gettype().tostring().tolower() = "system.data.dataset") then
newcount = _dg.datasource.tables(0).rows.count end if
if (newcount > 0) then pagecount = cint((newcount - 1) / _pagesize) if (_dg.currentpageindex > pagecount - 1) then _dg.currentpageindex = pagecount - 1 end if else