datagrid| Pagination | The control first adds to my previous post: When you use the user control I made in your project: Declare Protected DataGridPage1 as Datagridpage, which is the name of the control you dragged in before. After you define the user control. Then use your control in your code to write:
Datagridpage1.settarget (Mydatagrid, New binddatadelegate (AddressOf binddata))
Datagridpage1.setstyle (a False)
The underline part is the number of a binding you write yourself. Sub,function and so on.
Private Sub Page_Load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
' ページを initial するユーザーコードをここに 挿 into します.
If not IsPostBack Then
Dim ADP as SqlDataAdapter = New SqlDataAdapter ("select * from Orders", CN)
Dim DS as New DataSet
Adp. Fill (DS)
DV = ds. Tables (0). DefaultView
Catch ex as Exception
#If DEBUG Then
Session ("Error") = ex. ToString ()
Response.Redirect (".. /error.aspx ")
#End If
Finally
'??? Pick up
CN. Close ()
End Try
' Sort
Dv. Sort = StrSort
Return DV
End Function
Private Sub Mydatagrid_sortcommand (ByVal source as System.Object, ByVal e As System.Web.UI.WebControls.DataGridSortCommandEventArgs)
Mydatagrid.currentpageindex = 0
Private Sub Btngo_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Btngo.click
Dim Pagei as Integer
If (Txtgopage.text <> "") Then
Pagei = CInt (Trim (Txtgopage.text))-1
If (pagei >= 0 and Pagei < (mydatagrid.pagecount)) Then
Mydatagrid.currentpageindex = Pagei
End If
End If
ViewState ("strsort") = "OrderID"
Private Sub Showstatspage ()
Lblcurrentindex.text = "[<font color= ' Blue ' > as Before:" & (Mydatagrid.currentpageindex + 1) & "page </font>] "
Lblpagecount.text = "[<font color= ' Blue ' > Total:" & mydatagrid.pagecount & "page </font>]"
End Sub
Private Sub LinkButton1_Click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Linkbutton1.click
Mydatagrid.currentpageindex = 0
ViewState ("strsort") = "OrderID"
Private Sub Linkbutton4_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Linkbutton4.click
Mydatagrid.currentpageindex = (mydatagrid.pagecount-1)
ViewState ("strsort") = "OrderID"
Private Sub Linkbutton2_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Linkbutton2.click
If (Mydatagrid.currentpageindex > 0) Then
Mydatagrid.currentpageindex = mydatagrid.currentpageindex-1
ViewState ("strsort") = "OrderID"
Mydatagrid.databind ()
Showstatspage ()
End If
End Sub
Private Sub Linkbutton3_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Linkbutton3.click
If (Mydatagrid.currentpageindex < (mydatagrid.pagecount-1)) Then
Mydatagrid.currentpageindex = Mydatagrid.currentpageindex + 1
ViewState ("strsort") = "OrderID"
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.