' Insert page code here
'
dim pagesize as integer = 5
sub bindlist(byval pageno as integer)
dim conn as new oledbconnection()
dim cmd as new oledbcommand()
conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("guestbook.mdb")
conn.open()
cmd.connection=conn
cmd.commandtext="select * from book order by posttime desc"
dim objadpt as new oledbdataadapter(cmd)
dim ds as new dataset()
objadpt.fill(ds,"book")
conn.close()
dim book as datatable=ds.tables("book")
dim totalrec as integer=book.rows.count
showtotalrec.text=totalrec
dim totalpage as integer
if totalrec < pagesize then
totalpage=1
else
if totalrec mod pagesize <> 0 then
totalpage=totalrec\pagesize+1
else
totalpage=totalrec/pagesize
end if
end if
showtotalpage.text=totalpage
showcurrentpage.text=pageno
dim tempbook as datatable=book.clone()
dim i,j as integer
for i=(pageno-1)*pagesize to pageno*pagesize-1
if i<0 or i>book.rows.count-1 then exit for
dim row as datarow=tempbook.newrow()
for j=0 to book.columns.count-1
row(book.columns(j).columnname)=book.rows(i).item(j)
next
tempbook.rows.add(row)
next
guestbook.datasource=tempbook
guestbook.databind()
end sub
sub enabledwhatbutton()
if session("currpage")=1 then
firstbtn.enabled=false
prebtn.enabled=false
else
firstbtn.enabled=true
prebtn.enabled=true
end if
if session("currpage")=showtotalpage.text then
nextbtn.enabled=false
lastbtn.enabled=false
else
nextbtn.enabled=true
lastbtn.enabled=true
end if
end sub
sub pagechange(sender as object,e as commandeventargs)
select case e.commandargument
case "firstpage"
session("currpage")=1
case "prepage"
session("currpage")- = 1
case "nextpage"
session("currpage")+=1
case "lastpage"
session("currpage")=showtotalpage.text
case "postrec"
response.redirect("post.aspx")
case "manage"
response.redirect("adminlogin.aspx")
end select
bindlist(session("currpage"))
enabledwhatbutton()
end sub
sub page_init(sender as object,e as eventargs)
bindlist(session("currpage"))
enabledwhatbutton()
end sub
email is neither a DataColumn nor a DataRelation for table book.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: email is neither a DataColumn nor a DataRelation for table book.
Source Error:
Line 148: 留言人:<%# container.dataitem("name")%></td>
Line 149: <td>
Line 150: E-mail:<a href="mailto:<%# container.dataitem("email")%>"> <%# container.dataitem("email")%></a></td>
Line 151: </td>
Line 152: <td bgcolor="#eeeeee">作者: n煲 时间: 2009-12-25 21:05
楼主强呀,这样贴子也能发表出来,对你佩服之心比长江的水还多哦