DDL not firing

Discussion in 'ASP .Net' started by Guest, Jun 2, 2005.

  1. Guest

    Guest Guest

    How do I get a Dropdownlist to fire when the user selects an element? My
    code is:

    Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal
    e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

    Dim selectedItem = DropDownList1.SelectedValue
    Me.Label1.Text = "" + selectedItem + ""
    End Sub
     
    Guest, Jun 2, 2005
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Hi Niggy,

    Make sure your asp:dropdownlist tag has the runat="server" atrribute, and
    that the event is wired up correctly in the InitialiseComponent sub.

    HTH


    Dan
     
    Guest, Jun 2, 2005
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Thanks Dan. Runat="server" is ok, but there is no reference to an event in
    the InitialiseComponent sub. What should I put?
     
    Guest, Jun 2, 2005
    #3
  4. Guest

    Guest Guest

    Yip. AutoPostBack=true. Still not carrying out any action.
     
    Guest, Jun 2, 2005
    #4
  5. Guest

    Guest Guest

    Hi Niggy,

    In C#, I would write the following line in InitialiseComponent...

    this.DropDownList1.SelectedIndexChanged += new
    System.EventHandler(this.yourfunction)

    I'm not sure of the VB syntax though, sorry!

    Dan
     
    Guest, Jun 2, 2005
    #5
  6. Can you please show where you are placing the AutoPostBack?
     
    Patrick Olurotimi Ige, Jun 2, 2005
    #6
  7. Guest

    Guest Guest

    <asp:dropdownlist id=DropDownList3 style="Z-INDEX: 104; LEFT: 120px;
    POSITION: absolute; TOP: 336px" runat="server" DataMember="operators"
    DataSource="<%# DataSet21 %>" DataTextField="Username"
    DataValueField="Customer_id" AutoPostBack="True"></asp:dropdownlist>
     
    Guest, Jun 2, 2005
    #7
  8. <asp:DropDownList ID="DDL1" Runat="server" AutoPostBack="true">

    </asp:DropDownList>
     
    Juan T. Llibre, Jun 2, 2005
    #8
  9. Make sure AutoPostBack = true

    Eliyahu
     
    Eliyahu Goldin, Jun 2, 2005
    #9
  10. Your DropDownList looks ok about "SelectedIndexChanged"?
     
    Patrick Olurotimi Ige, Jun 2, 2005
    #10
  11. Don't put anything there. It is supposed to be autocreated. Either go to
    designer view, open the ddl properties and set the event there, or, even
    better, in the html view add an event handler attribute to the ddl tag as
    OnSelectedIndexChanged = DropDownList1_SelectedIndexChanged. And make
    DropDownList1_SelectedIndexChanged Protected instead of Private.

    Eliyahu
     
    Eliyahu Goldin, Jun 2, 2005
    #11
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.