Solved

Determining the first and last row in a DataSet

Posted on 2007-12-06
1
205 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Groupbox Control ? 2 27
IDE for Python 5 62
Data organization issue 7 36
Error building VS2105 solution from repository 1 33
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

713 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