Binding data to gridview
Into my gridview, How can i display only even numbered records from dataset?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 19, 2013, 9:05 PM EDT
Else we can get the records only required.
Sreekanth ReddyRank #726 · 3.2K reputationPosted Oct 19, 2013, 9:22 PM EDT
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Oct 19, 2013, 9:50 PM EDT
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;