CatManDave
MIS
Guys,
I'm trying to load a listbox with database values and set multiple select values at the same time.
For instance, I select an administrative assistant from a drop down box which kicks off the selected index change event which grabs the selected value of the drop down box and reposts the page. As the page reloads, I am taking the selected value and reading a doctor table for doctor records with that admin. assistant value and saving the doctor IDs in a comma delimited array.
At the point where the doctor listbox is displayed, I want to list all the doctors in the table and have the appropriate doctors selected according to the admin assistant selected from the aforementioned drop down box.
Here's a code snippet that simply displays all the doctors from the doctor table to the listbox. You can see the doctor list and where I have it in an array but I don't know where to go from here. How do I code the listbox to highlight the doctors associated with the admin assistant selected from the drop down box?
wrkarry = Split(docList, ",")
phyBound = UBound(wrkarry)
indx = 0
cmd = New SqlCommand( _
"SELECT DrID, DrInit FROM PhyDoctor " _
& "ORDER BY DrInit", cnn)
cnn.Open()
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While rdr.Read
lbPhy.Items.Add(New ListItem(rdr "DrInit"), rdr("DrID")))
End While
rdr.Close()
Thanks in advance for your help. It's definitely frustrating going from ASP to ASP.net with a lack of training materials and documentation on what I would consider basic language techniques. This is why I am a member.
-Dave
I'm trying to load a listbox with database values and set multiple select values at the same time.
For instance, I select an administrative assistant from a drop down box which kicks off the selected index change event which grabs the selected value of the drop down box and reposts the page. As the page reloads, I am taking the selected value and reading a doctor table for doctor records with that admin. assistant value and saving the doctor IDs in a comma delimited array.
At the point where the doctor listbox is displayed, I want to list all the doctors in the table and have the appropriate doctors selected according to the admin assistant selected from the aforementioned drop down box.
Here's a code snippet that simply displays all the doctors from the doctor table to the listbox. You can see the doctor list and where I have it in an array but I don't know where to go from here. How do I code the listbox to highlight the doctors associated with the admin assistant selected from the drop down box?
wrkarry = Split(docList, ",")
phyBound = UBound(wrkarry)
indx = 0
cmd = New SqlCommand( _
"SELECT DrID, DrInit FROM PhyDoctor " _
& "ORDER BY DrInit", cnn)
cnn.Open()
rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While rdr.Read
lbPhy.Items.Add(New ListItem(rdr "DrInit"), rdr("DrID")))
End While
rdr.Close()
Thanks in advance for your help. It's definitely frustrating going from ASP to ASP.net with a lack of training materials and documentation on what I would consider basic language techniques. This is why I am a member.
-Dave