Okay.
I also thought it may have had something to do with me moving the JobTitle column in the ApplicantsDataGridView. I modified the SQL query that populates the DGV and that column ended up in a different place.
Main Topics
Browse All TopicsIn my attached Job/Applicant matching application I'm all of a sudden getting thei "Operator '=' is not defined for type 'DBNull' and type 'Integer' (line 177).
It happens when I select a row in the ApplicantsDataGridView (top one) and select a row in the JobTitlesDataGridView (bottom one) then click the Assign Job Title button (btnUpdatePosition)
Function getJobTitleIndex(ByVal ID As Integer) As Integer
For Each row As DataGridViewRow In Me.JobTitlesDataGridView.R
If row.Cells(19).Value = ID Then
Return row.Index
End If
Next
End Function
Function getApplicantIndex(ByVal ID As Integer) As Integer
For Each row As DataGridViewRow In Me.ApplicantsDataGridView.
If row.Cells(5).Value = ID Then ' <----- #### The Error happens here ####
Return row.Index
End If
Next
End Function
Private Sub btnUpdatePosition_Click(By
' ' -=== Assign Worksite to Youth Button ===-
' 'Call the function to get the currently selected row of JobTitlesDataGridView
'Dim myPreviousValue As Long = Me.JobTitlesDataGridView.S
' Stores the current row number
' Check if there's any selected row
'If Not Me.JobTitlesDataGridView.S
If Me.JobTitlesDataGridView.S
'If Not Me.ApplicantsDataGridView.
If Me.ApplicantsDataGridView.
Dim SelectedID As Integer = Me.JobTitlesDataGridView.C
Dim SelectedID2 As Integer = Me.ApplicantsDataGridView.
Me.Cursor = Cursors.WaitCursor
Call UpdateAll()
Call RefreshAll()
Me.Cursor = Cursors.Default
' Set the old position
Dim DGVindex As Integer = getJobTitleIndex(SelectedI
Me.JobTitlesDataGridView.C
Me.JobTitlesDataGridView.R
Me.JobTitlesDataGridView.F
Dim DGVindex2 As Integer = getApplicantIndex(Selected
Me.ApplicantsDataGridView.
Me.ApplicantsDataGridView.
Me.ApplicantsDataGridView.
Me.JobTitlesDataGridView.C
Me.ApplicantsDataGridView.
Else
Exit Sub
End If
End If
''Restore the previously selected row after an update.
'Dim myRowIndex As Integer = getDGindex(myPreviousValue
'Me.JobTitlesDataGridView.
'Me.JobTitlesDataGridView.
''Maybe put here UpdateTotals() then RefreshAll() 'Note for 20090312
''UpdateTotals() is already called in UpdateAll()
End Sub
I jut don't know enough to know how to fix it. Assistance appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Okay, I think that fixed it.
Now, if I could just get the selected row to stay selected when I update the grids. The users are complaining that when they select an applicant and select a Job Title and click "Assign Job Title" they loose track of that applicant they just changed because it jumps to the top of the list and they loose the selection. Plus it crappy dog slow.
Thank you. I'm going to accept "Check for thecorrect column" as the solution to the original question, but could you please give me an example of the "set that row selected true" code above?
I think I've got too much redundant code unselecting and selecting rows. It's so messy I can't figure it out. I wrote very little of the code myself; it's mostly code pasted in from examples and solutions to problems I posted here on EE. ;-)
I'm the sole developer in my organizations so I don't have anyone to check my code for sanity.
Or else first get the row index by checking the ID Condition like
For each row in gridview
if (grdID = ID) then
irow = row.index
End If
Next
After that
DataGridView1.FirstDisplay
DataGridView1.Refresh()
DataGridView1.CurrentCell = DataGridView1.Rows(counter
DataGridView1.Rows(counter
Business Accounts
Answer for Membership
by: srikanthreddyn143Posted on 2009-04-20 at 15:02:10ID: 24189176
Check if row.Cells(5).Value, that value is Null. That exception is because you are comparing a null value with integer.