?
Solved

get row number of dataset.table(tableName).rows.find(findKey)

Posted on 2004-04-06
4
Medium Priority
?
2,347 Views
Last Modified: 2012-05-04
dataset.table(tableName).rows.find(findKey) returns a datarow this is all well and good if you want the actual information in that row however i need the numerical value of that row. is it possible to use find or something similar to return the row number of the found value
0
Comment
Question by:BangorCC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
gregasm earned 2000 total points
ID: 10771067
I cannot think of any way to do it easily.

But one way that you can is to enumerate the rows and increment a counter.

public int findRow(string colname, string criteria)
{

     for (int i = 0; i < table.rows.count; i++)
     {
           if (table.rows[i].column[colname] == criteria)
                {
                       return i;
                }
     }
     return -1;
}
0
 
LVL 8

Assisted Solution

by:gregasm
gregasm earned 2000 total points
ID: 10771084
another way to do it is to add an autoincrement column to the table.

see here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatacolumnclassautoincrementtopic.asp

and then when you use find(), you can retrieve the associated id of the increment column.
0
 

Author Comment

by:BangorCC
ID: 10783268
Yea thats what i thought... it really doesnt make that much sense not to at least have a separate function for finding a record position.
0
 
LVL 4

Expert Comment

by:RichW
ID: 11004594
I don't really think there is a way to get the current row from a dataset, but you can do this from a control that is bound to the dataset, say, like the Datagrid object, by performing a hitTtest.


Dim myGrid As DataGrid = CType(sender, DataGrid)
Dim myHitInfo As DataGrid.HitTestInfo = myGrid.HitTest(e.X, e.Y)
Dim Row As DataRow
Dim intRow as Integer

intRow = myHitInfo.Row '<==  Current selected row




0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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