在加载更多按钮单击时,将项目添加到更新面板中的datalist [英] Add items to datalist in update panel on load more button click

查看:107
本文介绍了在加载更多按钮单击时,将项目添加到更新面板中的datalist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。

我有一个包含datalist控件的更新面板这个数据列表的Item Template中有一些标签。

以下是我需要做的:

最初datalist将显示数据库中的前50行。

当我点击加载更多按钮时,会有一个部分回发,它将从中获取50多行数据库。

现在,我之前使用过的一种方法是获取(旧行+新50)并将这个新数据表重新分配给datalist。

但是,这个策略有问题。当需要太多的数据时间时,一次又一次地获取它们会在服务器上产生负载。

所以我想要的是:在加载更多按钮点击时,应该只获取新的50行。旧数据应该在datalist中保持不变,新数据应该附加到datalist。



我尝试过:



不知道怎么做这种方法。

Hi.
I have an update panel which contains a datalist control There are some labels inside the Item Template of this datalist.
Following is what I need to do:
Initially datalist will show top 50 rows from the database.
When I click on load more button, there will be a partial postback which will fetch 50 more rows from the database.
Now, one approach that I have used earlier is to fetch (old rows + new 50) and re-assign this new datatable to the datalist.
However, this strategy has a problem. When too many data times are required, fetching all of them again and again creates load on server.
So what I want is that: On load more button click, only new 50 rows should be fetched. Old data should remain intact inside datalist and the new data should be appended to the datalist.

What I have tried:

Donot know how to do this approach.

推荐答案

首先,请不要使用UpdatePanel来执行此操作。您可以改为使用AJAX加载页面上的下一个结果集。当您滚动或单击更多按钮时,您可以应用无限滚动的概念来加载其余数据。



看一下这个例子: http://www.aspsnippets.com/Articles/Load-data-while-Scrolling-Page-down-with-jQuery-AJAX-and-ASPNet。 aspx [ ^ ]



只需在谷歌快速搜索,即可在网上找到更多示例。
First off, don't use UpdatePanel to do this. You can instead use AJAX to load the next result set on the page. You can apply the concept of "infinite scroll" to load the rest of the data while you scroll or click on the more button.

Take a look at this for example: http://www.aspsnippets.com/Articles/Load-data-while-Scrolling-Page-down-with-jQuery-AJAX-and-ASPNet.aspx[^]

Just do a quick search in google to find more examples in the web.


这篇关于在加载更多按钮单击时,将项目添加到更新面板中的datalist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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