Solved

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

Posted on 2004-04-06
4
2,338 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
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
gregasm earned 500 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 500 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now