最好的方法是在ASP.net中的Web应用程序中获取Paging概念的数据 [英] Best way get the data for Paging concept in web applcaitions in ASP.net

查看:54
本文介绍了最好的方法是在ASP.net中的Web应用程序中获取Paging概念的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

提前谢谢



任何机构都可以解释在我的方案中编写代码的最佳方式



我有一些表的数据库,我必须在页面中显示数据库中的数据(每页包含20行)我正在做我的应用程序 - 我检索数据从数据每行20行,每次使用SP显示每个页面,每个页面点击我连接到sql并显示数据到前端页面。



我的想法是 - 在单个查询执行(单次迭代)中将完整数据输入到数据表中并将数据存储在会话中并在每次单击页面中使用它。



这种方式是否正确?



这是获取每页点击数据的最佳方式。



再次感谢。

Hi all,
Thanks in advance

Can any body explain the which is best way writing code in my scenario

I have data base with some tables, I have to show data from the database in pages (contains 20 rows in each page) i am doing my app is - iam retrieving the data from data by 20 rows each and every time for showing in a each page using SP, every page click i connected to sql and showing data in to Front End Page.

My idea is - to get complete data in to datatable in one single Query execution(single iteration) and store the data in session and use it in every page click.

Is this way is Correct or not?

and which is best way to get the data of every page click .

Thanks inadvance once again.

推荐答案

不要将数据放入Session。大量数据会降低应用程序的性能。我想给出一个建议



1.您在与数据库的单次交互中从数据库中检索100条记录。

2.你把缓存中的这些记录。

3.从缓存中显示数据意味着从网格缓存中检索20条记录。

4.当您到达第6,11,16页时...然后再次获取接下来的100条记录并用新记录更新缓存。



谢谢,

Sandeep
Don't put Data in to Session. Large amount data can reduce the performance of application. I want to give a suggestion that

1. You retrieve 100 records from data base in single interaction with Database.
2. You put these records in cache.
3. Show data from cache means retrieve 20 record from the cache on grid.
4. When you reach on page number 6,11,16...then again fetch next 100 records and update cache with new records.

Thanks,
Sandeep

不是要走的路。

这样想。分页是为了使应用程序更具响应性,并且显示更容易为用户消化。

如果您有几百万条数据记录并且一次性检索它们,那么您将创建广泛的性能问题更不用说使用一个非常大的会话对象了。

这样做的正确方法是在每次连续调用服务器时只选择你想要的数据页。
Not the way to go.
Think of it this way. Paging is there to make the application more responsive and the display easier to digest for the user.
If you have a couple million records of data and you retrieve it all at once then you will create an extensive performance issue not to mention using a ridiculously large session object.
The proper way to do this would be to select only the page of data you want on each successive call to the server.


是的,你的解释是正确的。您可以向页面添加一些数据容器(例如gridview),获取大型数据集(例如表格),并将控件的数据源设置为数据集。您可以在ViewState或Session中缓存数据集,具体取决于它是仅适用于您的页面还是整个应用程序。您在控件上配置分页,并处理页面事件以重置要显示的整个数据集的子集页面。



不是一个完整的示例,而是突出显示重要的件:

PAGE:

Yes, your explanation is correct. You add some data container to your page (say a gridview), get a large dataset (say a table), and set the datasource of the control to the dataset. You can cache your dataset in ViewState or Session depending on whether it is applicable to only your page, or your whole application. You configure paging on the control, and handle the page events to reset which subset page of the whole dataset to display.

Not a complete example, but to highlight the important pieces:
PAGE:
<asp:gridview id="gvData" runat="server" allowpaging="true" pagesize="20"></asp:gridview>





代码:



CODE:

Private Sub gvData_PageIndexChanging(sender As Object, e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles gvData.PageIndexChanging
    gvData.PageIndex = e.NewPageIndex
    gvData.DataSource = ViewState(DATA_NAME)
    gvData.DataBind
End Sub


这篇关于最好的方法是在ASP.net中的Web应用程序中获取Paging概念的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆