views:

30

answers:

1

Hi all,

I have a formview that is bound to an object data source. The object that is it bound to has certain nullable fields such as dates etc.

When the textbox that the user enters the date is empty if I do not intercept the formviews iteminserting/updating events and change the e.NewValues["datefield"] to null then the datasource gets called and the date field is set to 1/1/1901 (DateTime.MinValue).

Is there a more automatic way to stop this conversion of a blank textfield to a DateTime.MinValue without having to intercepet the formviews events? I see with a gridview if you have boundfields there is a way to do something like this but I cant see a similar way with a formview.

A: 

yes, it can be very easily..

<asp:Parameter Name="" Type="DateTime" ConvertEmptyStringToNull="true" />

in your objectdatasource control, set ConvertEmptyStringToNull="true" in your update parameter

Muhammad Akhtar
The problem is more that that the properties of the object that gets passed to the update method aren't set, I am not calling the update method specifically with individual parameters.I will post example code when I get a chance.
Daniel