Thanks in advance.
List<Entity>
How to get Top(10) rows from a List object and how to skip(10) rows and display the result. A sample app would be great.
Thanks in advance.
Thanks in advance.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Raaj KumarRank #7,836 · 233 reputationPosted Feb 25, 2010, 5:38 AM EST
This can be achieved through Linq with Take and Skip method,
List
for (int i = 0; i < 100; i++)
{
emplist.Add(new Employee() { Name = "Name_"+i.ToString(), Sex = "m" });
}
var first10Items = (from n in emplist select n).Take(10).ToList
dataGridView1.DataSource = first10Items;
var skippedItems = (from n in emplist select n).Skip(10).ToList
dataGridView2.DataSource = skippedItems;
I have attached a sample app as you per request.
Regards,
raaj
Van Matiz18 reputationPosted Feb 25, 2010, 5:43 AM EST