T
T
thatside2015-05-09 19:06:10
C++ / C#
thatside, 2015-05-09 19:06:10

How to change data before saving in Entity Framework + DataGridView?

There is a datagridview with bound data from the Entity Framework - the model. One of the fields is external and can be NULL. But, when I pick up values ​​for it from another table, when I click on the field itself, the first record from the external table is automatically selected, and I want to leave the option to leave NULL in this field. I tried to add a new empty record with id = 0 - it is still recognized as a value, and I get a foreign key error when saving the data. Is it possible to somehow change something in the data before saving?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
thatside, 2015-05-10
@thatside

I solved the problem like this: when changing the data in the desired column (CellValueChanged event), I check which one is set, and if 0 is set, I change it to null.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question