bjr, je suis debutante en asp.net et j'aimerai savoir comment faire si je selectionne une valeur id dans un dropdownlist (lie a la base de donnees)apres cela s'affichera dans un autre champ le contenu correspondant du id. Voici le code que j'ai trouve mais ca ne marche pas:
rivate Sub ddl_CDT_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_CDT.SelectedIndexChanged
Dim objreader_ddl_CDT As SqlClient.SqlDataReader
Dim objparam_ddl_CDT As SqlClient.SqlParameter
Dim connectstring_ddl_CDT As String = "uid=sa;password=ravaka;database=mtpm_patrimoine;server=(local)"
Dim connection_ddl_CDT As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectstring_ddl_CDT)
Dim objcommand_ddl_CDT As SqlClient.SqlCommand = New SqlClient.SqlCommand("select * from chef_depot where (
num_matricule_CDT=@num_matricule", connection_ddl_CDT)
objparam_ddl_CDT = objcommand_ddl_CDT.Parameters.Add("@num_matricule", SqlDbType.VarChar, 50)
objparam_ddl_CDT.Direction = ParameterDirection.Input
objparam_ddl_CDT.Value = ddl_CDT.SelectedItem.Text
Try
objcommand_ddl_CDT.Connection.Open()
objreader_ddl_CDT = objcommand_ddl_CDT.ExecuteReader(CommandBehavior.Default)
Catch ex As Exception
Response.Write("error to connect into database$" + "<br>")
End Try
While objreader_ddl_CDT.Read
If (objreader_ddl_CDT.GetValue(0) <> "") Then
txt_nom_CDT.Text = objreader_ddl_CDT.GetValue(1)
End If
End While
objreader_ddl_CDT.Close()
objcommand_ddl_CDT.Connection.Close()
End Sub
Merci a tout ce qui veut me repondre!