Solved

Determining the first and last row in a DataSet

Posted on 2007-12-06
1
200 Views
Last Modified: 2013-12-16
Hi,

I have a DataSet and I need to determine if the current row is the first or last?

I have something like this in my code:

DataRow dr = myDataSet.Tables["tableName"].Rows[recNum]

Please help.
0
Comment
Question by:EEssam
1 Comment
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20424738
Like this:
int index = dr.Table.Rows.IndexOf(dr);
if (index == 0) {
   // first
}
if (index == dr.Table.Rows.Count - 1) {
   // last
}

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question