<%@ Import NameSpace="System.Data.OleDb" %>
<%@ Import NameSpace="System.Data" %>
<HTML>
<HEAD>
<script language="vb" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack() Then
intPageSize.Text = "2"
intCurrIndex.Text = "0"
DataBind()
End If
End Sub
Private Sub DataBind()
Dim CnString As String
CnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
CnString = CnString + Server.MapPath("dataDB.mdb"))
Dim objConn As New OleDbConnection(CnString)
Dim objDA As New OleDbDataAdapter("SELECT * FROM Document ORDER BY CreateDate DESC", objConn)
Dim objDS As New DataSet()
If Not Page.IsPostBack() Then
objDA.Fill(objDS)
intRecordCount.Text = CStr(objDS.Tables(0).Rows.Count)
objDS = Nothing
objDS = New DataSet()
End If
dList.DataSource = objDS.Tables(0).DefaultView
dList.DataBind()
objConn.Close()
PrintStatus()
End Sub
Public Sub ShowFirst(ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Text = "0"
DataBind()
End Sub
Public Sub ShowPrevious(ByVal s As Object, ByVal e As EventArgs)
intCurrIndex.Text = Cstr(Cint(intCurrIndex.Text) - CInt(intPageSize.Text))
If CInt(intCurrIndex.Text) < 0 Then
intCurrIndex.Text = "0"
End If
DataBind()
End Sub
Public Sub ShowNext(ByVal s As Object, ByVal e As EventArgs)
If CInt(intCurrIndex.Text) + 1 < CInt(intRecordCount.Text) Then
intCurrIndex.Text = CStr(CInt(intCurrIndex.Text) + CInt(intPageSize.Text))
End If
DataBind()
End Sub
Public Sub ShowLast(ByVal s As Object, ByVal e As EventArgs)
Dim tmpInt as Integer
tmpInt = CInt(intRecordCount.Text) Mod CInt(intPageSize.Text)
If tmpInt > 0 Then
intCurrIndex.Text = Cstr(CInt(intRecordCount.Text) - tmpInt)
Else
intCurrIndex.Text = Cstr(CInt(intRecordCount.Text) - CInt(intPageSize.Text))
End If
DataBind()
End Sub
Dim Pagesize,Pagecount,RecordNum,CurrentPage as integer
dim userid as string
dim strtype as string
Sub Page_Load(sender As System.Object, e As System.EventArgs)
dim strconstring as string
dim strconstring2 as string
dim strconstring3 as string
dim conquanliwen as oledbconnection
dim strtype as string
strconstring = ConfigurationSettings.AppSettings("connectionString")
strconstring2 = Server.MapPath(ConfigurationSettings.AppSettings("connectionString2"))
strconstring3 = strconstring & strconstring2
conquanliwen = new oledbconnection (strconstring3)
conquanliwen.open()
'BindDroplList
Dim cmdSelect As oledbCommand
Dim dtrtype As oledbDataReader
Dim cmdSelect2 As oledbCommand
Dim dtrtype2 As oledbDataReader
cmdSelect = New oledbCommand( "Select * From Producetype", conquanliwen)
dtrtype = cmdSelect.ExecuteReader()
cmdSelect2 = New oledbCommand( "Select * From Producetype", conquanliwen)
dtrtype2 = cmdSelect2.ExecuteReader()
dlsttype.DataSource = dtrtype2
dlsttype.DataBind()
dtrtype2.Close()
Pagesize=10
'联接数据库
Dim cmdcount as oledbCommand = new oledbCommand("select count(*) as nID from ProduceIntro",conquanliwen)
Dim dtrcount as oledbDataReader = cmdcount.ExecuteReader()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
if dtrcount.Read() then
RecordNum =dtrcount("nID")
else
RecordNum = 0
end if
dtrcount.Close()
conquanliwen.close()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'计算总共有多少页
if Recordnum mod pagesize=0 then
PageCount = RecordNum\PageSize
else
PageCount = RecordNum\PageSize +1
end if
ViewState("PageCount") = PageCount
If Not IsPostBack then
CurrentPage = 0
ViewState("PageIndex") = 0
BindDataList
end if
End Sub
Sub Page_OnClick(sender As Object, e As CommandEventArgs)
CurrentPage = ViewState("PageIndex")
PageCount = ViewState("PageCount")
Dim cmd as string = e.CommandName
select case cmd
case "next":
if CurrentPage<(PageCount-1) then CurrentPage+=1
case "prev":
if CurrentPage>0 then CurrentPage-=1
end select
ViewState("PageIndex") = CurrentPage
BindDataList
End Sub
Sub btngoPage_Click(sender As Object, e As EventArgs)
CurrentPage = ViewState("PageIndex")
PageCount = ViewState("PageCount")
If txtgopage.text = "" then
CurrentPage = ViewState("PageIndex")
Else
CurrentPage = txtgopage.text - 1
If CurrentPage > PageCount - 1 then
CurrentPage = PageCount - 1
Else
CurrentPage = txtgopage.text - 1
End If
End If
ViewState("PageIndex") = CurrentPage
BindDataList
End Sub
Sub BindDataList
dim strconstring as string
dim strconstring2 as string
dim strconstring3 as string
dim conquanliwen as oledbconnection
dim strtype as string
strconstring = ConfigurationSettings.AppSettings("connectionString")
strconstring2 = Server.MapPath(ConfigurationSettings.AppSettings("connectionString2"))
strconstring3 = strconstring & strconstring2
Dim StartIndex as integer
conquanliwen = new oledbconnection (strconstring3)
StartIndex = CurrentPage*PageSize
Dim strSelect as string = "select * from ProduceIntro"
Dim dst as DataSet = new DataSet()
Dim Dadproduce as oledbDataAdapter = new oledbDataAdapter(strSelect,conquanliwen)
Dadproduce.Fill(dst,StartIndex,PageSize,"ProduceIntro")