Navigating within a dataset

Navigating within a dataset

Post by cG1jZ3Vpcm » Thu, 06 May 2004 02:06:07


I want to navigate to a specific record within a dataset.datatable. Some of my controls are bound to this datatable, and it would be nice to do something like

me.bindingcontext(MyDataset.MyDatatable).position=MyDataset.MyDatatable.FindByMyKeyFiel

But since the Position property is an integer, this obviously doesn't work. Instead Ive been looping through the entire table (i.e.

Me.BindingContext(MyDataset.MyDataTable).Position =
While Not Me.BindingContext(MyDataset.MyDataTable).Current("MyKeyField") = keyvalu
Me.BindingContext(MyDataset.MyDataTable).Position = Me.BindingContext(MyDataset.MyDataTable).Position +
End Whil

). This just seems wrong to me. Is there a better way?
 
 
 

Navigating within a dataset

Post by Cor Ligthe » Thu, 06 May 2004 02:26:50

Hi PMCguire,

I find it a nice routine you have made. Do not forget that underdeck a
shorter method would almost always do the same as your routine.

You can make it look nicer by first making a currencymanager as this
cma as new directcast(bindingcontext(mydataset.mydatatabble)
,currencymanager)
cma.Position = 0
While Not cma.Current("MyKeyField") = keyvalue
cma.Position += 1

However I see also no better alternative at the moment.

Cor