|
-
May 29th, 2004, 06:58 AM
#1
Thread Starter
New Member
Object Reference not set to instance of object
I have the following code (which I have used before with no prob) and continue to get an error that is baffling me. I'm doing a databind to a lable and passing the value to a format routine so I can control output on things like dates. Error is ...
An unhandled exception of type 'System.NullReferenceException' occurred in .....
Additional information: Object reference not set to an instance of an object.
CODE:
With m_objData
RMADataGrid.DataSource = .RMA
Dim objBinding As Binding
m_cmrRMA = _
CType(BindingContext(.RMA), _
CurrencyManager)
lblRMADate.DataBindings.Add(New _
Binding("Text", .RMA, "RMA Date"))
AddHandler objBinding.Format, _ <<< Chokes here
AddressOf FormatLabelAsDateString
........................................
Private Sub FormatLabelAsDateString(ByVal sender As Object, _
ByVal cevent As ConvertEventArgs)
If cevent.DesiredType Is GetType(String) Then
If cevent.Value Is DBNull.Value Then
cevent.Value = ""
Else
cevent.Value = Convert.ToDateTime(cevent.Value).ToString("d")
End If
End If
End Sub
Any suggestions would be most appreciated. Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|