I'm working on trying to populate a bunch of controls with data. These controls include Comboboxes, textboxes, date/time etc.
I initially let the user make their selections/enter data and save the records. For comboboxes, i displayed text, however, save a value, as an example...
ValueMember DisplayMember
100 Accounting
101 Finance
In this case, if user selected Accounting, I saved it as 100.
Now I'm trying to populate these controls with the correct data and set the selections to what they were at the point of saving this record.
This is how I'm getting the data...
dim querystring as string
dim count as integer
QueryString = "Select FirstName, LastName, Dept, Position from TblClients where IdClient = 1112"
Dim cmd As New SqlCommand(queryString, Conn)
Conn.Open()
Using sdA As New SqlDataAdapter
Using dtA As New DataTable
sdA.SelectCommand = cmd
count = sdA.Fill(dtA)
If count <> 0 Then
MsgBox("Success")
End If
cboContactCategory.SelectedValue = dtA.Rows(0)("Dept").ToString
End Using
End Using
Conn.Close()
FirstName = txtFirst; LastName = txtLast, Position = cboPosition, Dept = cboDept
How would I go about setting these values?