R
runningdog
I have a dataset contining sorted data in mutilple tables from which I am
selecting rows to action.
I use the Find method of the DefaultView from a specific Table to get the
position of a row in the table.
I then set the position of the BindingContext to action the row.
eg.
Table.DatafaultView.Sort = "ColumnName"
pos=Table.DatafaultView.Find(key)
BindingContext(DataSet,Table).Position = pos
This works fine to switch between existing rows.
When I add a row to the DataSet (without updating the DataAdpter, because I
don't want to save the changes at this point) the above method returns
incorrect rows.
eg. If the existing data looks like this
pos Key
------------
0 123
1 234
2 345
and I then add the record 111
pos=Table.DatafaultView.Find(111) will return 0 as it should.
BindingContext(DataSet,Table).Position = 0 will bind to 123
pos=Table.DatafaultView.Find(123) will return 1
BindingContext(DataSet,Table).Position = 1 will bind to 234
So it appears that the data in the DataSet looks like
pos Key
------------
0 123
1 234
2 345
3 111
Is there something I need to do, after an Table.Rows.Add(row), to the
DefaultView or DataSet to have it rebuild its sort index?
TIA Steve
selecting rows to action.
I use the Find method of the DefaultView from a specific Table to get the
position of a row in the table.
I then set the position of the BindingContext to action the row.
eg.
Table.DatafaultView.Sort = "ColumnName"
pos=Table.DatafaultView.Find(key)
BindingContext(DataSet,Table).Position = pos
This works fine to switch between existing rows.
When I add a row to the DataSet (without updating the DataAdpter, because I
don't want to save the changes at this point) the above method returns
incorrect rows.
eg. If the existing data looks like this
pos Key
------------
0 123
1 234
2 345
and I then add the record 111
pos=Table.DatafaultView.Find(111) will return 0 as it should.
BindingContext(DataSet,Table).Position = 0 will bind to 123
pos=Table.DatafaultView.Find(123) will return 1
BindingContext(DataSet,Table).Position = 1 will bind to 234
So it appears that the data in the DataSet looks like
pos Key
------------
0 123
1 234
2 345
3 111
Is there something I need to do, after an Table.Rows.Add(row), to the
DefaultView or DataSet to have it rebuild its sort index?
TIA Steve