开发者

Problem Datagridview and Foreign & Primary key column

开发者 https://www.devze.com 2023-03-30 01:18 出处:网络
I have a datagridview in which the first column is a Foreign Key and part of the Primary key of a table (Linq2sql). I use a combobox for selecting a proper Foreign Key value.

I have a datagridview in which the first column is a Foreign Key and part of the Primary key of a table (Linq2sql). I use a combobox for selecting a proper Foreign Key value.

The thing is that as soon as I want to edit a (new) row it immediately throws an error "DataGridViewComboBoxCell value is not valid". I assume this is because it's value is r开发者_如何学Goequired and hence cannot be null (Linq makes it type "int", which does not allow null).

Do I need to supply a default value for the combobox and if so, how/where can I do this?


Handle the DefaultValuesNeeded event

0

精彩评论

暂无评论...
验证码 换一张
取 消