Solved

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

Posted on 2004-04-06
4
2,342 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

696 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