I have some problems getting the value from the selcted index of a dropdown List. Nothing happens when I click the mat-list. Here is my code:
Code:Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then bindMaterialer() End If End Sub Protected Sub bindMaterialer() Dim strCn As String = "Provider=Microsoft.jet.oledb.4.0;" strCn += "Data Source=" & Server.MapPath("priser.mdb") & ";" Dim cn As OleDbConnection = New OleDbConnection(strCn) Dim cmdText As String = "Select Id as matId, Materiale FROM MedieMatNy Order By Id" Dim cmd As OleDbCommand = New OleDbCommand(cmdText, cn) cmd.Connection.Open() mat.DataSource = cmd.ExecuteReader() mat.DataValueField = "matId" mat.DataTextField = "Materiale" mat.DataBind() cmd.Connection.Close() End Sub Public Sub mat_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mat.SelectedIndexChanged Dim strHpl As String = mat.SelectedItem.Text Label4.Text = strHpl End Sub




