⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagingsorting.vb

📁 聊天 聊天 聊天 聊天 聊天 聊天
💻 VB
字号:
Imports System
Imports System.Collections
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class BaseClass
Inherits System.Web.UI.Page
Protected Grid1 as DataGrid
Dim myConnection As OleDbConnection
Dim myCommand    As OleDbDataAdapter
Dim ds           As New DataSet
Dim ConnStr      As String
Dim SQL          As String
Public SortField As String
Sub Page_Load(Source As Object, E As EventArgs) 
   ConnStr = "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=ASPNET;User ID=sa;"
   myConnection = New OleDbConnection(ConnStr)      
    if NOT (isPostBack)
    	If SortField = "" Then
		 SortField = "code_display"
	End If
	rebind
    end if	
End Sub
Sub ReBind()
	'DataSetCommand
	SQL = "select  m.*, g.code_display as category "
	SQL = SQL + "from masters m,  groups g "
	SQL = SQL + " where m.code_category = g.code_value"
	myCommand = New OleDbDataAdapter(SQL, myConnection)
	'use Fill method of DataSetCommand to populate dataset
	myCommand.Fill(ds, "masters")
	
	'Sort accounding to sortField
	Dim dv2 as DataView 
	dv2 = ds.Tables("masters").DefaultView
	dv2.Sort = SortField 
	Grid1.DataSource= dv2
	Grid1.DataBind()
	
End Sub

Sub MyDataGrid_Page(sender As Object, e As DataGridPageChangedEventArgs)
	Grid1.CurrentPageIndex = e.NewPageIndex
	ReBind
End Sub
Sub MyDataGrid_Sort(sender As Object, e As DataGridSortCommandEventArgs)
	 SortField = e.SortExpression
	ReBind
End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -