DDL not firing

Discussion in 'ASP .Net' started by =?Utf-8?B?TmlnZ3k=?=, Jun 2, 2005.

  1. 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
     
    =?Utf-8?B?TmlnZ3k=?=, Jun 2, 2005
    #1
    1. Advertising

  2. 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

    "Niggy" wrote:

    > 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
     
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Jun 2, 2005
    #2
    1. Advertising

  3. Thanks Dan. Runat="server" is ok, but there is no reference to an event in
    the InitialiseComponent sub. What should I put?
     
    =?Utf-8?B?TmlnZ3k=?=, Jun 2, 2005
    #3
  4. Yip. AutoPostBack=true. Still not carrying out any action.

    "Eliyahu Goldin" wrote:

    > Make sure AutoPostBack = true
    >
    > Eliyahu
    >
    > "Niggy" <> wrote in message
    > news:...
    > > 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

    >
    >
    >
     
    =?Utf-8?B?TmlnZ3k=?=, Jun 2, 2005
    #4
  5. 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


    "Niggy" wrote:

    > Yip. AutoPostBack=true. Still not carrying out any action.
    >
    > "Eliyahu Goldin" wrote:
    >
    > > Make sure AutoPostBack = true
    > >
    > > Eliyahu
    > >
    > > "Niggy" <> wrote in message
    > > news:...
    > > > 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

    > >
    > >
    > >
     
    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Jun 2, 2005
    #5
  6. Patrick Olurotimi Ige, Jun 2, 2005
    #6
  7. <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>

    "Patrick Olurotimi Ige" wrote:

    > Can you please show where you are placing the AutoPostBack?
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    =?Utf-8?B?TmlnZ3k=?=, Jun 2, 2005
    #7
  8. <asp:DropDownList ID="DDL1" Runat="server" AutoPostBack="true">

    </asp:DropDownList>



    Juan T. Llibre
    ASP.NET MVP
    http://asp.net.do/foros/
    Foros de ASP.NET en EspaƱol
    Ven, y hablemos de ASP.NET...
    ======================


    "Patrick Olurotimi Ige" <> wrote in message
    news:...
    > Can you please show where you are placing the AutoPostBack?
     
    Juan T. Llibre, Jun 2, 2005
    #8
  9. Make sure AutoPostBack = true

    Eliyahu

    "Niggy" <> wrote in message
    news:...
    > 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
     
    Eliyahu Goldin, Jun 2, 2005
    #9
  10. 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

    "Niggy" <> wrote in message
    news:D...
    > Thanks Dan. Runat="server" is ok, but there is no reference to an event

    in
    > the InitialiseComponent sub. What should I put?
    >
    >
     
    Eliyahu Goldin, Jun 2, 2005
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. huobazi

    Can NOt AutoPostBack for two DDL

    huobazi, Jul 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    508
    huobazi
    Jul 2, 2003
  2. Marina
    Replies:
    0
    Views:
    920
    Marina
    Aug 12, 2003
  3. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    why is ddl.selectedValue not retained in viewstate ?

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Oct 3, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    497
    JIMCO Software
    Oct 4, 2005
  4. Groove
    Replies:
    1
    Views:
    532
    Groove
    May 17, 2006
  5. Groove
    Replies:
    0
    Views:
    567
    Groove
    May 18, 2006
Loading...

Share This Page