How to DataBind TextBox to a Typed DataRow Field that allows Nulls?

  • Thread starter Thread starter Ryan0827
  • Start date Start date
R

Ryan0827

Guest
I'm trying to bind textboxes and dropdown controls to a strongly typed datarow. Some of the rows fields allow nulls which is throwing an exception because the Binding class seems to try to access TypeDataRow.PropertyName directly and not testing for NULL using the IsPropertyNameNull() method.

How do I two-way bind my controls to a typed datarow that allows nulls in some of its properties?

Me.TextBox.DataBindings.Add("Text", TypedDataRow, PropertyName, True, DataSourceUpdateMode.OnPropertyChanged, Nothing)


' typed datarow field
Public Property PropertyName() As Decimal
Get
Try
Return CType(Me(Me.TypedTable.PropertyNameColumn),Decimal)
Catch e As Global.System.InvalidCastException
Throw New Global.System.Data.StrongTypingException("The value for column 'PropertyName' in table 'Lists' is DBNull.", e)
End Try
End Get
Set
Me(Me.TypedTable.PropertyNameColumn) = value
End Set
End Property




Ryan

Continue reading...
 
Back
Top