Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormView ConvertEmptyStringToNull and binding

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.

like image 897
Scott Ivey Avatar asked Apr 15 '09 20:04

Scott Ivey


1 Answers

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.

like image 122
devMomentum Avatar answered Sep 20 '22 03:09

devMomentum