Figure out position, when dataset is Bound

mcerk

Well-known member
Joined
Nov 1, 2004
Messages
78
I have 2 tables in my Dataset. They are related with a constraint.

I use Datagrid to move thru records and textboxes to edit values. Textbox Databindig text properties are set to my Dataset. When I set Databinding to the DataGrid everything works fine.
Code:
Me.DataGrid1.SetDataBinding(Me.DataSet, "Table1")

My textboxes show current record selected in datagrid. OK. that is fine. But I want to manually fill some other records. That is why I would like to find out "Table1.id" field of selected DataGrid record.

How can I do this?

BTW: this code doesnt work when DataGrid.SetDataBinding is set, but works, if DataGrid.SetDatabinding is not set!!!!!!!!
Code:
I need this code, to figure out Table1.id of selected record.
dim variableID as Integer 
variableID = Me.DataSet.Table1.Rows(Me.BindingContext(Me.DataSet.Table1).Position).Item("id")

So my question is, how can I change code for variableID, that it will worke while datagrid Databinding is set????


tx

matej
 
I believe what you are looking for is:
Code:
variableID = Me.BindingContext(Me.DataSet, "Table1").Current("id")

Me.BindingContext(Me.DataSet, "Table1") is not the same as Me.BindingContext(Me.DataSet.Table1), and will be different binding contexts
 
Back
Top