data binding

  • Thread starter Thread starter Nice Chap
  • Start date Start date
N

Nice Chap

We are experiencing problems during data binding. If the text property
of the control is bound to a datacolumn, when the user clears the field and
tabs out, the textbox puts the original value back. This is particularly
for Date and numeric fields. I feel that the datarow is rejecting the value
being passed ( which would be string.empty? and Columnchange gets
cancelled). I would expect a value a of DBNull to be passed to the datarow
when the user clears the field. Is there some property I can set to prevent
the old value from reappearing when the user clears a field ?
 
Hi Nice Chap,

I think you mean something as this?

Cor
\\\
Private Sub myroutine()
Mybinding = New Binding("Text", ds.Tables(0), "mydatfield")
textdatfield.DataBindings.Add(Mybinding)
AddHandler mybinding.Format, AddressOf DBdateTextbox
AddHandler mybinding.Parse, AddressOf TextBoxDBdate
End sub
Private Sub DBdateTextbox(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
Dim datum As Date
datum = CDate(cevent.Value)
cevent.Value = datum.ToString("dd - MM - yyyy")
End If
End Sub
Private Sub TextBoxDBdate(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.Value.ToString = "" Then
cevent.Value = DBNull.Value
End If
End Sub
///
 
Back
Top