请谁能给一个完整的ASP.NET的取SQL数据库中表内容且有分页的代码? 要求分页采用存储过程的! 要求分页快!要求是完整的ASP.NET代码! 请谁能提供出来,马上给分!
解决方案 »
- 请高手帮忙把一小段JAVA代码翻译成C#,在线等
- web用戶控件裡面的图片路径改怎么设置?
- 一页只能有一个服务器端 Form 标记,不是一般问题!
- 紧急求助关于excel中的.Net 数据 OLE DB 提供程序(System.Data.OleDb)要求 Microsoft 数据访问组件(MDAC) 2.6 或更高版本
- 这个问题如何解决?
- DataList嵌套后,怎么设置第二层的事件?如ItemCommand.....
- 请大家帮忙
- 如何将后台代码中的变量值,付给前台页面中的javascript中的变量?
- 如何获得SQL所得数据的行数?在asp中的<!--#include file ="XX.aspx" -->不能用了?
- 哪里有ASP初级资料
- 高分求救(关于Cache)
- 常数和数据库连接放到哪里?
建议 你去http://www.webdiyer.com/看看
ALTER procedure UserPager
(@pagesize int,
@pageindex int,
@docount bit)
/*分页存储过程*/
as
set nocount on
if(@docount=1)
select count(id) from [user]
else
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select id from [user] order by id desc
select O.id,O.username from [user] O,@indextable t where O.id=t.nid
and t.id>@PageLowerBound and t.id<=@PageUpperBound order by t.id
end
set nocount off
'========================ADMINLIB.VB '读取全部用户
Public Function GetAllUser(ByVal pageindex As Integer, ByVal pagesize As Integer, ByVal docount As Boolean)
Dim strConn As New PublicLib
Dim Conn As New SqlConnection(strConn.strconn)
Dim Comm As New SqlCommand("UserPager", Conn)
Comm.CommandType = CommandType.StoredProcedure
Comm.Parameters.Add("@pageindex", pageindex)
Comm.Parameters.Add("@pagesize", pagesize)
Comm.Parameters.Add("@docount", docount)
Conn.Open()
Return Comm.ExecuteReader(CommandBehavior.CloseConnection)
End Function
'这个作用是读取用户的总数用于分页
Public Function LoadGetAllUser()
Dim strConn As New PublicLib
Dim Conn As New SqlConnection(strConn.strconn)
Dim Comm As New SqlCommand("UserPager", Conn)
Comm.CommandType = CommandType.StoredProcedure
Comm.Parameters.Add("@pageindex", 1)
Comm.Parameters.Add("@pagesize", 1)
Comm.Parameters.Add("@docount", True)
Dim CountNum As Integer
Conn.Open()
CountNum = Comm.ExecuteScalar
Conn.Close()
Return CountNum
End Function'======表示层 Function DataGrid1DataBind()
Dim GetAllUser As New AdminLib
'读出用户总数
Dim PageSize As Integer = 18 '每页显示数
Dim CurrentPageIndex As Integer '开始页面
Dim PageCount As Integer '页总数
Dim UserCount As Integer = GetAllUser.LoadGetAllUser() '用户个数
If UserCount Mod PageSize = 0 Then '计算页数.构造URL分页
PageCount = UserCount \ PageSize
Else
PageCount = UserCount \ PageSize + 1
End If If Request.Params("PageID") Is Nothing Then
CurrentPageIndex = 1
Else
CurrentPageIndex = CInt(Request.QueryString("PageID"))
End If
Dim i As Integer
Dim PagerUrl As String
If PageCount = 1 Then
PagerUrl = "<a href=UserAdmin.aspx?PageID=1 target=main> 1 </a>"
Else
For i = 0 To PageCount - 1
PagerUrl += "<a href=UserAdmin.aspx?PageID=" & i + 1 & " target=main>" & i + 1 & "</a> "
Next
End If
strPageurl.Text = PagerUrl
DataGrid1.DataSource = GetAllUser.GetAllUser(CurrentPageIndex, PageSize, False) '参数说明开始页面,页面大小 False ,如果是读取总数就为True
DataGrid1.DataKeyField = "id"
DataGrid1.DataBind()
End Function
为了更好交流学习asp.net 和.net技术,china825将为如下用户,免费提供.net 空间及sql server数据库.1. bbs.china825.com论坛版块版主(300积分以上)
2. 公开提供下载资10个以上.
3. 为本站论坛推广多达200人上.
4. 公开提供论坛插件模式设计方法并提供相应插件一套,随anf升级变化.
5. 公开提供论坛其它功能模块或设计,被采用者.
6. 论坛发贴质量含量高,数量及积分较高者.可提出申请,经批准者.
7. .net有一定水平,有自己的产品,苦于没有空间,可提出申请,经批准者.注册用户满足以上任一条即可提出申请,经批准提供一定大小.net空间,根据需要相应提供sql server数据库. 礼 小宝
http://bbs.china825.com/74/ShowPost.aspx#74