I have an order table with the following columns:
orderid, clientid, [columns for order details] ...
I am then displaying this table, for a specific client, using a DataGridView. I have both the orderid
and clientid
columns hidden, however, as the orderid
is a autonumbered primary key and the clientid
is constant.
Unfortunately, when new rows are added to the DataGridView they are not persisted to the database. I believe this is because the orderid
defaults to -1 and/or the clientid
defaults to null whenever a new row is inserted into the DataGridView, but because those columns are hidden the user cannot change them.
So, my question:
How can I get the orderid
to be selected automatically and have the clientid
default to the currently displayed client, whenever a new row is inserted?