wifi连接显示已保存:急,求助,asp.net(vb.net)datalist分页程序代码如下,怎么不行?谢先!

来源:百度文库 编辑:高校问答 时间:2024/05/08 17:33:06
asp.net(vb.net)datalist分页程序代码如下,怎么不行?谢先!就是“下一页”按钮处理不行,只能加显示第二页,再点击就不行了,还是显示第二页。不知道是为什么,我为这个困了有些时日了,一直苦于找不出原因,请大家帮小弟看看,望不吝赐教!!谢谢!

<%@ page language="vb" debug="true" %>
<%@ import namespace="system.data"%>
<%@ import namespace="system.data.sqlclient"%>
<script runat="server">

dim pagesize as integer=cint(configurationsettings.appSettings("pagesize"))

'页面载入时初始代码
sub page_load(o as object, e as eventargs)

showindex.text=1
'初始绑定

call binddata()

end sub

'数据绑定
public sub binddata()

dim conn as sqlconnection
dim comm as sqldataadapter
dim sqlstr as string
dim ds as dataset
dim pageindex as integer
conn = New SqlConnection( configurationsettings.appSettings("connstr") )
comm = new sqldataadapter("inisearch",conn)
comm.selectcommand.commandtype=commandtype.storedprocedure
conn.open()
ds=new dataset()
'这里添加页面选择相关处理程序

pageindex=cint(showindex.text)
if pageindex*pagesize>cint(application("rowsall"))
comm.fill(ds,(pageindex-1)*pagesize,cint(application("rowsall"))-(pageindex-1)*pagesize,"pics")
showindex.text=pageindex.tostring
else

comm.fill(ds,(pageindex-1)*pagesize,pagesize,"pics")
showindex.text=cstr(pageindex+1)
end if
mydatalist.datasource=ds.tables("pics")
mydatalist.databind()
conn.close()
end sub

'页面选取
sub p_first(o as object, e as eventargs)
end sub

sub p_prior(o as object, e as eventargs)
end sub

sub p_next(o as object, e as eventargs)

dim pageindex,rowsall as integer
pageindex=cint(showindex.text)
rowsall=cint(application("rowsall"))

if pageindex*pagesize>rowsall then
call binddata()
else
call binddata()
pageindex=pageindex+1
showindex.text=pageindex.tostring
end if

end sub

sub p_last(o as object, e as eventargs)
end sub

</script>
<html>
<body bgcolor="gray">
<form runat="server">
<asp:table width="50%" runat="server">
<asp:tablerow>
<asp:tablecell>
<asp:datalist id="mydatalist" bordercolor=green datakeyfield="pid" gridlines=both repeatdirection="horizontal" repeatcolumns="6" runat="server">
<itemtemplate>

<%# databinder.eval(container.dataitem,"pid" ) %>
<%# "<asp:tablerow><asp:tablecell>"%>
<%# "<img src=" & databinder.eval(container.dataitem,"purl") & ">"%>
<%# "</asp:tablecell></asp:tablerow>"%>
</itemtemplate>
</asp:datalist>
</asp:tablecell>
</asp:tablerow>
<asp:tablerow>
<asp:tablecell>
<asp:linkbutton id="first" text="首页" onclick="p_first" runat="server"/> 
<asp:linkbutton id="prior" text="上一页" runat="server"/> 
<asp:linkbutton id="next" text="下一页" onclick="p_next" runat="server"/> 
<asp:linkbutton id="last" text="尾页" runat="server"/>
</asp:tablecell>
</asp:tablerow>

</asp:table>
<asp:label id="showindex" runat="server" />
</form>
</body>
</html>

<asp:linkbutton id="first" text="首页" onclick="p_first" runat="server"/>
<asp:linkbutton id="next" text="下一页" onclick="p_next" runat="server"/>
这两行中,onclick是没有用的,只会在客户端运行
VB不会,但我知道在C#中是这样的:
在page_onload()
中加入this.first.onclick+= new System.EventHandler(this.p_first)
this.next.onclick+= new System.EventHandler(this.p_next)