Dumbfounded by Datagrids

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am my wit's end with trying to use a datagrid to update a dataset. I can
get it to work for one row, but not muliple rows. I know what you're going
to say. Use endcurrentedit. I tried that but still does not work. All I
want to do is put up a datagrid bound to a dataset. After the user modifies
rows, he hits a button to update the original database. When I do this and
debug the datarowstate, not all rows show modified. Here is the code.

To load the grid:
dstable2.Clear()
dstable2 = TableDB.ListTable2 ' this is a class that gets data and fills
the dataset.
Tablegrid.SetDataBinding(dstable2, "Table2")

When the user presses the SAVE button:
BindingContext(dstable2.Tables(0)).EndCurrentEdit()

After this, if I loop through each row and check it's datarowstate, only
some rows show as modified, usually only the ones where I moved the cursor to
the next row.
The last row modified never shows as modified.

What's wrong?
 
Hi Mark.
Are you calling .Update on the data adapter?
Also, are you calling .AcceptChanges on the dataset tables?
And don't forget you have to refresh the data from SQL Server to see your
changes.
HTH
Ron.
 
Mark,

The only thing that jumps out at me is the BindingContext thing. There are
two ways to specify a BindingContext, and they end up being two different
objects.

So, when you say:

BindingContext(dstable2.Tables(0)).EndCurrentEdit()

perhaps you should be using:

BindingContext(dstable2, "MyTableName").EndCurrentEdit()

I'm not really sure that this is the problem, I'm just guessing. I prefer
the first syntax, but perhaps somehow in the way you've set up your
DataBinding to the grid, it automatically assumed the second syntax?

Couldn't hurt to try and see what happens.

~~Bonnie
 
Back
Top