i have a asp.net repeater control .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 ?
+1
A:
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();
rockinthesixstring
2010-10-06 03:52:28
@rockinthesixstring - hehe, nice work copying my comment. you thief! :)
RPM1984
2010-10-06 03:58:44
sorry didn't see the comment. I just thought about it after I made my original post. NOTE: all credit to the first option be to RPM :-p
rockinthesixstring
2010-10-06 04:03:40
no probs, i'm just winding you up anyway. :)
RPM1984
2010-10-06 04:04:35
also, sorry for hacking this together.. I keep having to go back to the code converter since I'm a VB guy :(
rockinthesixstring
2010-10-06 04:10:12
A:
You can also use the PagedDataSource class, this class encapsulates the paging related properties of a data-bound control.
vinayak
2010-10-06 05:54:09