大量数据如何在前台页面显示?

talkactive 2009-06-05 09:06:09
查询的数据量比较大,当绑定到gridview时,显示的时间比较长,而且容易假死,想问一下如何才能保证数据的正常显示呢?
...全文
90 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hanhenry 2009-06-05
  • 打赏
  • 举报
回复
用分页吧~~~
yezie 2009-06-05
  • 打赏
  • 举报
回复
分页吧,一次读取很占内存,也费性能
cc_net 2009-06-05
  • 打赏
  • 举报
回复
标记下
cloudfang 2009-06-05
  • 打赏
  • 举报
回复
分页存储过程

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


create procedure [dbo].[Proc_DataPager]
(
@TableName nvarchar(12), --表名
@PageSize int, --分页大小
@PageCur int, --当前页码
@QueryField nvarchar(256)='*', --要查询的字段
@StrWhere nvarchar(256)='', --查询条件
@SortField nvarchar(12), --排序字段
@AscOrDesc int=0 --排序方式0降序1升序
)
as
begin

declare @BeginIndex int --开始查询索引位置
declare @EndIndex int --结束查询索引位置
declare @SortType nvarchar(12) --排序方式
declare @StrSQL nvarchar(3000) --sql查询语句

set @BeginIndex=@PageSize*@PageCur
set @EndIndex=@BeginIndex+@PageSize

if @AscOrDesc=0
set @SortType=' desc'
else
set @SortType=' asc'

set @StrSQL='select * from (select row_number() over (order by '+@SortField+@SortType+' ) as rn, '+@QueryField+' from '+@TableName

--查询条件不为空
if @StrWhere!=''
begin
set @StrSQL=@StrSQL+' where '+@StrWhere
end

set @StrSQL=@StrSQL+') as _table where rn>'+cast(@BeginIndex as nvarchar)+' and rn<='+cast(@EndIndex as nvarchar)

exec (@StrSQL)

end

Study_Work_2009 2009-06-05
  • 打赏
  • 举报
回复
使用自定义分页

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧