Kratz
Kratz

Reputation: 4340

FormView tries to insert Null from Blank TextBoxes

I'm using a FormView control with the EntityFramework. I'm trying to add a new record, but every time I leave a text box blank, instead of inserting an empty string, it tries to insert a null.

How do I control this behavior so that it will use an empty string instead of a null?

Upvotes: 0

Views: 568

Answers (1)

objectbox
objectbox

Reputation: 1281

you can handle this in the different levels of your application:

1) you can set default value in ItemCreated event handler and set default value there.

2) If you have permission to modify dblayer, you can set default value for column in db (or, maybe it is already set) and then set StoreGenerationPattern to Computed (look at, for example Entity Model - How to use Database's Default Column Values while inserting)

Upvotes: 2

Related Questions