Find Rowindex of Datarow

Hello,
I am trying to find rowindex of datarow( vb.net desktop). The code is as follows:
 Dim dtDgDiarySource As New DataTable
                                            dtDgtestSource = FrmMain.Dgtest.DataSource
                                            Dim rows As DataRow()
                                            rows = dtDgtestSource.Select("D_UID  = '" & row.Item("D_UID").ToString() & "'")

Open in new window


Cheers
RIASAsked:
Who is Participating?
 
AndyAinscowFreelance programmer / ConsultantCommented:
or maybe
dim rowindex as long = dtDgtestSource .Rows.IndexOf(rows[0])
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Do you mean which row is that you pull out from in the DataSource collection?
0
 
RIASAuthor Commented:
Yes, Andy :> Need the row index
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
RIASAuthor Commented:
Been struggling with this for quite sometime
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
I'd suggest a Foreach loop with a counter.  Break out of the loop when you find the row you want - the counter would then be the index of that row.
0
 
RIASAuthor Commented:
Yes Andy thanks for that but was trying to find some clever way ..
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Or does this work?
dim rowindex as long = dtDgtestSource .Rows.IndexOf(rows)
0
 
RIASAuthor Commented:
Thanks will try and brb
0
 
RIASAuthor Commented:
Thanks
0
 
RIASAuthor Commented:
Perfect!!!!!Thanks mate as always!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.