binding data to gridview
Into my gridview, How can i display only even numbered records from dataset?
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.
Jaganathan BantheswaranPosted Oct 20, 2013, 1:50 AM
You can use Linq2SQL like this,
var AfterRowNumbering = dataTable.Select((x, index) => new {
Id=x.Id,
......
......
Row_Number = index
});
var evenResult = from row in AfterRowNumbering
where row.Row_Number % 2 == 0
select row;
var oddResult = from row in AfterRowNumbering
where row.Row_Number % 2 != 0
select row;
Sreekanth ReddyPosted Oct 20, 2013, 1:22 AM
Jaganathan BantheswaranPosted Oct 20, 2013, 1:05 AM
Else we can get the records only required.