DataGrid paging problem (jump back and forth) "Control Edition"
Source: Internet
Author: User
datagrid| Pagination | control | The problem defines it in the user control. In. is written in ascx.
In the csdn see a lot of DataGrid paging problem, of course, the DataGrid has its own paging items, the function is very limited, I also saw a lot of csdn on the page of the code, found that are written in C #, I wrote a ASP. Net written in VB language. The following code for your reference.
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フォームデザイナで Generation されたコード"
' この call び out しはwebフォームデザイナで necessary です.
<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
' メモ: のプレースホルダ declaration はwebフォームデザイナで necessary です.
' Removes the および movement しないでください.
Private Designerplaceholderdeclaration as System.Object
Private Sub Page_Init (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Mybase.init
' codegen:このメソッド call び out しはwebフォームデザイナで necessary です.
' コードエディタを makes って becomes more しないでください.
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
' ページを initial するユーザーコードをここに 挿 into します.
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 ("a")
_DG. CurrentPageIndex = 0
Case ("PREVIOUS")
_DG. CurrentPageIndex = Math.max (_DG. CurrentPageIndex-1, 0)
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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service