views:

118

answers:

1

I've got a DevExpress TextEdit which is databound to a dataset.

The field is an optional percentage, (datatype double).

When the record gets loaded and there is no value in the field, everything is fine.

However, if you type something into the field (IE 100) and then want to remove it afterwards, I get an Invalid Value, error.

Why does this occur, and how can I remove it?

I do not have any mask or any sort of explicit validation on this field.

A: 

I have resolved this with the assistance of Brendon Muck on the DevExpress forums.

One of my TextEdit's was bound to the Text property instead of the EditValue (all should be bound to EditValue)

Also, per Brendon

Deleting the text out of the TextEdit control doesn't set the field to NULL. You'd have to handle the EditValueChanged event and manually set the value to null when an empty string is detected.

So, I have created method to handle it

Private Sub SetTextEditToNull(ByVal sender As TextEdit)

    If String.IsNullOrEmpty(sender.EditValue.ToString.Trim()) And (Not sender.EditValue Is DBNull.Value) Then

        sender.EditValue = DBNull.Value

    End If

End Sub

And in my event handler I use:

    SetTextEditToNull(CType(sender, TextEdit))
Nathan Koop