开发者

How to restrict repeater rows in asp.net

i have a asp.net repeater cont开发者_如何学Pythonrol .I have to display only two rows in the repeater .but my dataset has 10 rows ..is there a way to restrict the number of rows of a repater ?


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();


You can also use the PagedDataSource class, this class encapsulates the paging related properties of a data-bound control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜