Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-06
4
Medium Priority
?
2,351 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 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