I am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help
Please see code below
Dim strConn As String
strConn = ConfigurationSettings.AppSettings("connectionString")
Dim myConn As New SqlConnection(strConn)
Dim strSQL As String
strSQL = "select distinct EId, LName, FName, Mi " & _
" from EmpQualMain " & _
" where BrCode = '" & gBranchCode & "'" & _
" order by Lname, FName"
Dim myCommand As New SqlCommand(strSQL, myConn)
Dim myRead As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.Default)
cboEmpList.Items.Add(myRead.GetValue(myRead.GetOrdinal("LName")) + ", " + myRead.GetValue(myRead.GetOrdinal("FName")) + " " + myRead.GetValue(myRead.GetOrdinal("Mi")))
cboEmpList.DataValueField = myRead.GetValue(myRead.GetOrdinal("EId"))
Catch exc1 As Exception
If Not (myConn Is Nothing) Then
If myConn.State = System.Data.ConnectionState.Open Then myConn.Close()