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.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raaj KumarPosted Feb 25, 2010, 10:38 AM
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 MatizPosted Feb 25, 2010, 10:43 AM