datagrid 自定义分页问题
数据源是datareader是不是不能使用内置分页功能?
求自定义分页实例代码?vb的!
数据源是datareader是不是不能使用内置分页功能?
求自定义分页实例代码?vb的!
解决方案 »
- 这个要怎么做
- asp.net中 查询两个日期之间的所以记录
- 新手关于FORM验证的问题
- 怎样用Javascript在treeview某一节点前面插入一个新节点
- 在线等。。。。。。。。。。。。。。。。。
- 2003下如何装VS2003.net,急!!!!!!!!
- 高手们,该出手就出手吧!
- 怎样防止这样的攻击?
- asp.net + c#,一个cs文件一个dll,可以做到吗?
- ASP.Net 文本框输入数据后按回车,结果没执行预想功能键,反而是执行了页面第一个按钮
- datagrid中有一列选择按钮列,如何实现点击按钮将datagrid中的那行记录提取出来放到,textbox上?最好附上源代码
- 请问asp.net中那个控件可以实现热点链接功能?——用frontpage很容易的问题却难了我很久
--需要把排序字段放在第一列 (
@FirstID nvarchar(20)=null, --当前页面里的第一条记录的排序字段的值
@LastID nvarchar(20)=null, --当前页面里的最后一条记录的排序字段的值
@isNext bit=null, --true 1 :下一页;false 0:上一页
@allCount int output, --返回总记录数
@pageSize int output, --返回一页的记录数
@CurPage int --页号(第几页)0:第一页;-1最后一页。
)ASif @CurPage=0
begin
--统计总记录数
select @allCount=count(ProductId) from Product_test
set @pageSize=10
--返回第一页的数据
select top 10
ProductId,
ProductName,
Introduction
from Product_test order by ProductId
endelse if @CurPage=-1 select * from
(select top 10 ProductId,
ProductName,
Introduction from Product_test order by ProductId desc ) as aa
order by ProductId
else begin
if @isNext=1
--翻到下一页
select top 10 ProductId,
ProductName,
Introduction
from Product_test where ProductId > @LastID order by ProductId
else
--翻到上一页
select * from
(select top 10 ProductId,
ProductName,
Introduction
from Product_test where ProductId < @FirstID order by ProductId desc) as bb order by ProductId
end
声明:上述转载
2、http://dev.csdn.net/develop/article/52/52203.shtm
<%@ page language=vb debug=true%>
<%@ register tagprefix="romantic" namespace="fw" assembly="tec_message" %>
<html>
<head>
<title>
</title>
<style>
body{scrollbar-face-color:#FFCC99;scrollbar-track-color:#FFaa66;scrollbar-arrow-color:red;scrollbar-shadow-color:#FFaa99}
body{font-size:9pt}
table{font-size:9pt}
input{font-size:9pt}
a:link{text-decoration:none;color:#000000}
a:hover{text-decoration:none;color:red}
a:visited{text-decoration:none;color:#000000}
body{margin-top:10px;margin-left:0px;margin-bottom:5px;margin-right:0px}</style>
<script language=vb runat=server>
dim page1 as string
dim i,j as integer
dim n as integer
dim strsql as string
dim strcnn as string
dim thenote as string
sub page_load(sender as object, e as eventargs)
button11.attributes.add("onclick","return window.confirm('你要删除,确认吗?');")
page1=request("page")
bind()
if not ispostback then
bindgrid11()
end if
end sub
public function disp(filename as integer) as integer
n=dg.currentpageindex\10
return n
end functionfunction bindgrid11()
dim fw as new tec_message
dg.pagesize=10
dg.currentpageindex=page1
dg.datasource=fw.showarticle
dg.databind()
end functionsub bind()
dim fw as new tec_message
fw.count
thenote=fw.thenote
end subsub delete(sender as object, e as eventargs)
dim fw as new tec_message
fw.noteid=request.form("chk")
if fw.delete then
bindgrid11()
bind()
else
response.write("<script language='javascript'>alert('删除失败!');<" & chr(47) & "script>")
end if
end sub
</script>
</head>
<body bgcolor="#ffcc99">
<form runat=server>
<table width=100% cellpadding=2 cellspacing=1 bgcolor="#aab7b7">
<tr height=25><th background=new/tiao1.jpg>.NET技术</th></tr>
<tr bgcolor=#ffffff><td>
<asp:datagrid
id=dg
runat="server"
BorderWidth="0"
autocustompaging="true"
AutoGenerateColumns="false"
showheader=true
headerstyle-backcolor="#aa56a1"
cellpadding=2
cellspacing=1
allowpaging=true
backcolor=#ffcc99
width=100% >
<pagerstyle visible=false/>
<columns>
<asp:templatecolumn
headertext="删除"
headerstyle-height=23
headerstyle-width=5%
itemstyle-backcolor=#ffffff
itemstyle-horizontalalign=center>
<itemtemplate>
<input type='checkbox' name="chk" value='<%#databinder.eval(container.dataitem,"renoteid")%>'>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn
headertext="标题"
headerstyle-width=13%
itemstyle-backcolor=#ffffff
>
<itemtemplate>
<a href=tecview.aspx?noteid=<%# databinder.eval(container.dataitem,"noteid")%> target="_blank"><%#container.dataitem("title")%></a>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn
headertext="内容"
headerstyle-width=45%
itemstyle-backcolor=#ffffff
>
<itemtemplate>
<%#container.dataitem("content")%>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn
headertext="ip"
headerstyle-width=12%
itemstyle-backcolor=#ffffff
>
<itemtemplate>
<%#container.dataitem("ip")%>
</itemtemplate>
</asp:templatecolumn>
<asp:templatecolumn
headertext="时间"
headerstyle-width=13%
itemstyle-backcolor=#ffffff
>
<itemtemplate>
<%#container.dataitem("ttime")%>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
</td>
<tr bgcolor=#ffffff height=35><td>
总共<%=dg.pagecount%>页,共<%=thenote%>篇文章,当前第<font color=red><%=dg.currentpageindex+1%></font>页
<%
if dg.currentpageindex<>0 then
response.write("<a href='tec_message.aspx?page=0'><font face=webdings>9</font></a>")
else
response.write("<font face=webdings color=red>9</font>")
end if
%>
<% if page1>0 then
response.write("<a href='tec_message.aspx?page=" & dg.currentpageindex-1 &"'><font face=webdings>7</font></a>")
else
response.write("<font face=webdings color=red>7</font>")
end if
%>
<%
for i=0 to dg.pagecount-1
disp(dg.currentpageindex)
for j=n*10 to (n*10+9)
if j=dg.currentpageindex then
response.write("<font color=red>" & j+1 & "</font> ")
else
response.write("<a href='tec_message.aspx?&page=" & j &"'>" & j+1 & "</a> ")
end if
if j>dg.pagecount-2 then
exit for
end if
next j
exit for
next i
%>
<% if page1<dg.pagecount-1 then
response.write("<a href='tec_message.aspx?page=" & dg.currentpageindex+1 &"'><font face=webdings>8</font></a>")
else
response.write("<font face=webdings color=red>8</font>")
end if
%>
<% if page1<dg.pagecount-1 then
response.write("<a href='tec_message.aspx?page=" & dg.pagecount-1 &"'><font face=webdings>:</font></a>")
else
response.write("<font face=webdings color=red>:</font>")
end if
%>
</td></tr>
<tr bgcolor=#ffffff height=35><td>注意:左边复选框为删除选项,如果选择后点删除设置,则删除相应图片
如仅仅修改文件名,可在修改相应选项后直接点击修改设置 </td></tr>
<tr bgcolor=#ffffff height=35><td align=center><asp:button id=button11 runat=server text=确认删除 onclick="delete"/></td></tr>
</table>
<br>
</form>
</body>
</html>