I'm using a FormView with an ObjectDataSource and binding using <%# Bind("WhateverProp") %> - and all of my nullable columns are coming back with default values of the type in them.
It appears that the FormView object doesn't have a ConvertEmtpyStringToNull property like the other binding containers do. I've found articles suggesting that this was a bug in VS 2005 / .Net 2.0 - but don't see any saying what the resolution was.
Does anyone have any suggestions as to how I can work around this without just re-capturing all of the fields in the ODS_Inserting event? I'd rather not have to write code to re-bind all of my bound fields on the form just to test for nulls.
Struggled with it too. For a dropdownlist, I do that:
AppendDataBoundItems="true"
<asp:ListItem Text="" Value=""></asp:ListItem>
For my ObjectDataSource, even thoug my UpdateMethod takes a single parameter, the entity, I add Update params for each Nullable Field of the Entity with convert to NULL
<UpdateParameters>
<asp:Parameter Name="No_Empl_Ferme" Type="Int32" ConvertEmptyStringToNull="true" />
</UpdateParameters>
I do the same for the Insert.
Works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With