DropDownList asp.net et vb.net
Bonjour le Forum je souhaite dans mon DropDownList lorsque que je sélection un intitulé que le code qui est le champ clé primaire soit afficher.
dans mon application Windows j'utilise les événements 'SelectedIndexChanged' et 'DropDown'
mais ASP.net ne reconnais pas l'événement 'DropDown' quelqu'un pourrais m'aider à résoudre se problème?
voila le code que j'utilise dans mon application Windows
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
Try
'ceci transforme les intitules en code sur l evenement combobox_SelectedIndexChanged, en cas de selecction de la liste
'votre chaine de connection ici
Call Connecter()
Dim sql As String = "select NOM_FORURNISSEUR, IDFOURNISSEUR from FOURNISSEUR where NOM_FORURNISSEUR='" & ComboBox1.Text & "'"
Dim cmd = New SqlClient.SqlCommand(sql, con)
Dim ds As New DataSet
Dim adp = New SqlClient.SqlDataAdapter(cmd)
adp.Fill(ds, sql)
ComboBox1.DisplayMember = "IDFOURNISSEUR"
ComboBox1.ValueMember = "IDFOURNISSEUR"
Me.ComboBox1.DataSource = ds.Tables(sql)
Catch ex As Exception
End Try
End Sub
Private Sub ComboBox1_DropDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.DropDown
Try
'ceci au moment de derouler la liste, le combobox charge la liste des intitules. l'evenement sur combobox_dropdown
'votre chaine de connection ici
Call Connecter()
Dim sql As String = "select NOM_FORURNISSEUR, IDFOURNISSEUR from FOURNISSEUR"
Dim cmd = New SqlClient.SqlCommand(sql, con)
Dim ds As New DataSet
Dim adp = New SqlClient.SqlDataAdapter(cmd)
adp.Fill(ds, sql)
ComboBox1.DisplayMember = "NOM_FORURNISSEUR"
ComboBox1.ValueMember = "NOM_FORURNISSEUR"
Me.ComboBox1.DataSource = ds.Tables(sql)
Catch ex As Exception
End Try
End Sub |