troubleshooting Question

Check drop down list for value

Avatar of kdeutsch
kdeutschFlag for United States of America asked on
.NET ProgrammingASP.NETVisual Basic.NET
9 Comments1 Solution259 ViewsLast Modified:
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.



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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros