English 中文(简体)
获取网格/数据来源成果的数量有限?
原标题:Getting Limited number of results from gridview/datasource?

I have a gridview with a sql datasource. I have almost 35000 records which are being populated into the table. That usually hangs the system while loading from the server.

在从电网或数据来源取得结果时,是否有办法。

Something like it loads the first 1000 results first .. once the user is done going through those results, then it loads the next 1000 results automatically. I tried to use caching ...

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString=""           SelectCommand="SELECT * FROM [Table1]" EnableCaching="true" CacheDuration="3000" >

I assume this caches the data and all the other sql queries remain local to the cache instead of going to the database. But when I refresh the page, it loads all the records again and takes the same amount of time(a minute). So thats why I need something like loading the first 1000 records or something first.

问题回答

You could design your query according to GridView page size. Let suppose You are at page 1 of Gridview and page size is set to 100. Then just select first 100 records from the database.

您的网格能够绘制和确定页数财产

AllowPaging="true" 
PageSize="100"

你的格格言应该像在 as页上那样。

<asp:GridView runat="server" AllowPaging="true" PageSize="100"




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签