Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Do you mean which row is that you pull out from in the DataSource collection?
Avatar of RIAS

ASKER

Yes, Andy :> Need the row index
Avatar of RIAS

ASKER

Been struggling with this for quite sometime
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.
Avatar of RIAS

ASKER

Yes Andy thanks for that but was trying to find some clever way ..
Or does this work?
dim rowindex as long = dtDgtestSource .Rows.IndexOf(rows)
Avatar of RIAS

ASKER

Thanks will try and brb
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Thanks
Avatar of RIAS

ASKER

Perfect!!!!!Thanks mate as always!