Question NullReferanceException Occurred

Joined
Feb 13, 2009
Messages
12
Programming Experience
3-5
Hello,

I need help on the following: Object Reference not set to an instance of an object

Error Here: row = CType(CType(Me.TblCaseNoBindingSource.Current, DataRowView).Row, TSICaseNoDataSet.tblCaseNoRow)

I tried to check for null but can't find the right code to do so?


Private Sub JobIDComboBox_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JobIDComboBox.SelectedIndexChanged
Try
Dim mFilter As Integer = Me.JobIDComboBox.SelectedValue
Me.TblCaseNoBindingSource.Filter = String.Format("JobID = '{0}'", mFilter)

Dim row As TSICaseNoDataSet.tblCaseNoRow
row = CType(CType(Me.TblCaseNoBindingSource.Current, DataRowView).Row, TSICaseNoDataSet.tblCaseNoRow)
Dim ContFilter As Integer = row.PhoneID
Me.TblQuoteContactBindingSource1.Filter = String.Format("PhoneID = '{0}'", ContFilter)
Catch ex As Exception

End Try
End Sub

Thanks in advance,

Carl
 
All Good!

This Worked:

Private Sub JobIDComboBox_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles JobIDComboBox.SelectedIndexChanged
Try
Dim mFilter As Integer = Me.JobIDComboBox.SelectedValue
Me.TblCaseNoBindingSource.Filter = String.Format("JobID = '{0}'", mFilter)

If Me.TblCaseNoBindingSource.Current Is Nothing Then
Exit Sub
Else
Dim row As TSICaseNoDataSet.tblCaseNoRow
row = CType(CType(Me.TblCaseNoBindingSource.Current, DataRowView).Row, TSICaseNoDataSet.tblCaseNoRow)
Dim ContFilter As Integer = row.PhoneID
Me.TblQuoteContactBindingSource1.Filter = String.Format("PhoneID = '{0}'", ContFilter)
End If
Catch ex As Exception

End Try
End Sub
 
Back
Top