Results 1 to 6 of 6

Thread: Value from DrpList

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Value from DrpList

    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

  2. #2
    Hyperactive Member tailz's Avatar
    Join Date
    Jul 2002
    Posts
    306

    Lightbulb

    might be an idea to check you have the "autopostback" property set to true

    -----
    Gary
    Last edited by tailz; Jun 23rd, 2003 at 02:08 AM.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049
    Thanks, that was the only thing I forgot. Sometimes we're 2fast :-]

  4. #4
    Hyperactive Member tailz's Avatar
    Join Date
    Jul 2002
    Posts
    306
    glad I helped

  5. #5
    Member
    Join Date
    Aug 2002
    Location
    Pakistan
    Posts
    32

    Thanx

    I was facing the same prob ... you didnt help one guy but atleast 2 and am sure many more as well ....
    You'll get life just for once so don't waste it .......

  6. #6
    Member
    Join Date
    Aug 2002
    Location
    Pakistan
    Posts
    32

    Thanx

    I was facing the same prob ... you didnt help one guy but atleast 2 and am sure many more as well ....
    You'll get life just for once so don't waste it .......

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width