kdeutsch
asked on
Check drop down list for value
I need to check my drop down list for a value before I assign it the myDatatablerow, I have some instances where its not loading the data because its no longer there.
So what I do is load my ddlrecrutier dropdownlist on the page load and tehn i pull information about a person, but if there recruiter no longer exists it bombs out on the assigning of the recruit data to the dropdownlist, how can i check to see if recruiter is in list and it not assign it to zero, to make them pick a recruiter.
This is spot where is this number is not in the dropdownload it bombs out on me with this error
Specified argument was out of the range of valid values. Parameter name: 202
ddlRecruiter.SelectedValue = myDataTable.Rows(0)(23)
Meaning that persons recrutier is not in the page load of recruiters, so i need to check to see if its existing in the dropdown and if so then assign it else assign it to zero.
So what I do is load my ddlrecrutier dropdownlist on the page load and tehn i pull information about a person, but if there recruiter no longer exists it bombs out on the assigning of the recruit data to the dropdownlist, how can i check to see if recruiter is in list and it not assign it to zero, to make them pick a recruiter.
This is spot where is this number is not in the dropdownload it bombs out on me with this error
Specified argument was out of the range of valid values. Parameter name: 202
ddlRecruiter.SelectedValue
Meaning that persons recrutier is not in the page load of recruiters, so i need to check to see if its existing in the dropdown and if so then assign it else assign it to zero.
I do this on page load
Private Sub LoadRecruiters()
sql = "Select r.intRecruiterRecordID, w.strFullName from tblRecruiter as r INNER JOIN WORSDotNet.dbo.tblUser as w on w.intID = r.intRecruiterID where r.bitActive = 1 Order by " _
& "strFullName, intTeamID"
ddlRecruiter.Items.Add(New ListItem("Pick Recruiter", "0"))
buildDD(sql, ddlRecruiter)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok,
Heres waht i have but I get blue underlines under the not nothing protion, still a vb.net 1.1 project
Dim selRec As String = myDataTable.Rows(0)(23)
Dim I As ListItem = ddlRecruiter.Items.FindByV alue(selRe c)
If I Is Not Nothing Then
ddlRecruiter.SelectedValue = myDataTable.Rows(0)(23)
Else
ddlRecruiter.SelectedValue = "0"
End If
Heres waht i have but I get blue underlines under the not nothing protion, still a vb.net 1.1 project
Dim selRec As String = myDataTable.Rows(0)(23)
Dim I As ListItem = ddlRecruiter.Items.FindByV
If I Is Not Nothing Then
ddlRecruiter.SelectedValue
Else
ddlRecruiter.SelectedValue
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can do it other way also as following
If Not IsNothing(I) Then
If Not IsNothing(I) Then
ASKER
All,
Ok I got it working by the following, but if they hit refresh on the page I get this error which calls out the Dim line
Dim I As ListItem = ddlRecruiter.Items.FindByV alue(myDat aTable.Row s(0)(23))
If I Is Nothing Then
ddlRecruiter.SelectedValue = "0"
Else
ddlRecruiter.SelectedValue = myDataTable.Rows(0)(23)
End If
Object not set to reference, why would it get this.
Ok I got it working by the following, but if they hit refresh on the page I get this error which calls out the Dim line
Dim I As ListItem = ddlRecruiter.Items.FindByV
If I Is Nothing Then
ddlRecruiter.SelectedValue
Else
ddlRecruiter.SelectedValue
End If
Object not set to reference, why would it get this.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
all,
Ok Figured it out had it outside of my postback statment.
Ok Figured it out had it outside of my postback statment.
ASKER
Thanks
dim selRec as string = myDataTable.Rows(0)(23)
if ddlRecruiter.Items.Items.I
' assign
else
' assign to 0
end if