I am using a DataReader to fill a DropDownListBox using the following code:
It does a wonderful job except it keeps leaving out the first record in the table. In other words if there were four departments (Office, Yard, Garage, Fence), then only Yard, Garage, and Fence are showing up in the list.
Any ideas would be *very* helpful.
Thanks,
Eva
Code:
Private Sub FillDepartmentList()
Dim cmdDepartment As New SqlCommand("SELECT Department, DepartmentID FROM tb_Department", sqlCon)
Dim drDepartment As SqlDataReader = cmdDepartment.ExecuteReader
With ddlDepartment
While drDepartment.Read
.DataSource = drDepartment
.DataTextField = "Department"
.DataValueField = "DepartmentID"
.DataBind()
End While
.Items.Insert(0, New ListItem())
.SelectedIndex = 0
End With
drDepartment.Close()
End Sub
It does a wonderful job except it keeps leaving out the first record in the table. In other words if there were four departments (Office, Yard, Garage, Fence), then only Yard, Garage, and Fence are showing up in the list.
Any ideas would be *very* helpful.
Thanks,
Eva