1 2 3 4 5 6 7 8 9 10
| dim connexion as New SQLConnection(strcnx)
Dim reqSelectService as String="select serv_id,serv_nom from service"
command=New SqlCommand(reqSelectService, connexion)
connexion.Open()
Dim oReader As SqlDataReader = Command.ExecuteReader()
dim DropDownListService as New DropDownList()
While oReader.Read()
DropDownListService.Items.Add(new ListItem(oReader.GetInt32(0),oReader.GetString(1)))
End While
oReader.Close() |
C'est suffisant, il n'y a pas besoin de plus.
Ensuite, dans la mesure où ta dropdownlist est crée dynamiquement, il faut que tu l'ajoutes à ta page
maPage.controls.Add(DropDownListService )
en prenant garde à l'ordre de chargement de la page.
Partager