Registered User
Registered User

Reputation: 1564

Dynamically bound DataGridView shows -1 value on auto-increment column?

I've dynamically bind datagridview with my database table and ContactId column is autoincrement in my database table when i click on last row in gridview to insert data it shows me -1 then on next -2 when i save the contents and then again open it shows properly why such a behavior?

enter image description here

Upvotes: 2

Views: 996

Answers (1)

Henk Holterman
Henk Holterman

Reputation: 273314

The negative values are temporary keys. Needed to make proper foreign key relations etc. And indeed replaced when the Db generates the real keys.

Upvotes: 1

Related Questions