I have this code that will get the selected value from the combo and put in the parameter. The If statement will causes NullRefernceException ("obj ref not set to an instance of an obj") IF I typed a value which matchs one of the listed value, however, when I selected the value by mouse/keystroke, the code works fine. How can I change my if line to accomandate that goal?
arParms(0) = New SqlParameter("@P1_CSR", SqlDbType.Int)
If CType(cboCSR.SelectedItem, System.Data.DataRowView).Row("CSR").ToString = "" Then
arParms(0).Value = DBNull.Value
arParms(0).Value = cboCSR.SelectedValue
And here is how the combo got populated. By the way, the first row of the returned data are Null, Null.
dsOptions = SqlHelper.ExecuteDataset(cn_str_QWright_Dev, CommandType.StoredProcedure, "CT_getCSR")
dsOptions.Tables(0).TableName = "CSR"
cboCSR.DataSource = dsOptions.Tables("CSR")
cboCSR.DisplayMember = "CSR"
cboCSR.ValueMember = "EmployeeID"
Thanks in advance!