限制对一个ASP.NET的ListView结果数 [英] Limit the number of results on a ASP.NET ListView

查看:194
本文介绍了限制对一个ASP.NET的ListView结果数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须绑定到一个泛型列表集合一个ListView。

I have a ListView bound to a Generic List collection.

我需要能够限制势必像5项的数目,并显示在模板的more按钮。

I need to be able to limit the number of items bound to something like 5, and show a more button in the template.

我可以处理DataBinding事​​件,并删除列表&LT的最后几个项目;>,但一些事感觉不对。我还可以在列表中未限制在5事前,因为我需要知道,有超过5个,以显示更多按钮。

I can handle the DataBinding event, and remove the last few items in the List<>, but something about that doesn't feel right. I also can't limit the list to 5 beforehand, because I need to know that there are more than 5, to show the "more" button.

任何想法?谢谢!

推荐答案

数据绑定列表,以

yourlist.Take(5);

(即LINQ的运营商),但执行检查根据原名单上的更多的按钮。

(i.e. the LINQ operator), but perform the check for the more button based on the original list.

这篇关于限制对一个ASP.NET的ListView结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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