<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<Script Runat="Server">
Dim conNorthwind As SqlConnection
Dim strSql As String
Dim strSelect As String
Dim intStartIndex As Integer
Dim intEndIndex As Integer
Dim intRecordCount As Integer
Dim cmdSql As SqlCommand
Sub Page_Load
btnFirst.Text = "首页"
btnPrev.Text = "上一页"
btnNext.Text = "下一页"
btnLast.Text = "末页"
conNorthwind = New SqlConnection( "Server=192.168.4.1;UID=sa;PWD=111111;Database=yourDBname" )
If Not IsPostBack Then
BindDataGrid
End If
End Sub
Sub BindDataGrid
Dim cmdSelect As SqlCommand
Dim dtrRecordCount As SqlDataReader
intEndIndex = dgrdProducts.PageSize
cmdSelect = New SqlCommand( "newsPaged", conNorthwind )
cmdSelect.CommandType = CommandType.StoredProcedure
cmdSelect.Parameters.Add( "@PageIndex", intStartIndex )
cmdSelect.Parameters.Add( "@PageSize ", intEndIndex )
conNorthwind.Open()
dtrRecordCount = cmdSelect.ExecuteReader()
While dtrRecordCount.read()
intRecordCount=dtrRecordCount(0)
End While
dgrdProducts.VirtualItemCount = (intRecordCount / dgrdProducts.PageSize)
dtrRecordCount.NextResult()
dgrdProducts.DataSource = dtrRecordCount
dgrdProducts.DataBind()
conNorthwind.Close()
End Sub
Sub dgrdProducts_PageIndexChanged( s As Object, e A
| 对此文章发表了评论 |

