简体   繁体   中英

How to restrict repeater rows in asp.net

我有一个asp.net转发器控件。我必须在转发器中仅显示两行。但是我的数据集有10行..是否有办法限制转发器的行数?

I would Take the appropriate number of rows from your original DataSet

I don't have my IDE in front of me, but the idea is something like

Repeater1.DataSource = MyDataSet.Take(2).ToList();

Alternatively if you need to sort it, you could try something like this

Repeater1.DataSource = (from ds in MyDataSet
                        select ds
                        orderby SomeValue descending).Take(2); 

You can also skip the first X rows and then return 2

Repeater1.DataSource = MyDataSet.Skip(20).Take(2).ToList();

您还可以使用PagedDataSource类,该类封装了数据绑定控件的与页面调度相关的属性。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM