2 dropdownlists

Discussion in 'ASP .Net' started by Bart Schelkens, Aug 9, 2004.

  1. Hi,

    I have a webpage that contains 2 dropdownlists.

    One is displaying Categories and the other is displaying sub-categories.
    When I click on a categorie in the first dropdownlist, I want the second
    list to display
    the sub-categories for the selected category.

    I tried it using the SelectedIndexChanged but this doesn't fire until a
    submit of the page. Is there a way to have the desired effect whitout having
    to perform a submit ?

    Thanks.
     
    Bart Schelkens, Aug 9, 2004
    #1
    1. Advertising

  2. Set the AutoPostBack property of the Categories drop down list to true

    --
    Steve Willcock, MCSD
    http://www.willcockconsulting.com/

    "Bart Schelkens" <> wrote in message
    news:...
    > Hi,
    >
    > I have a webpage that contains 2 dropdownlists.
    >
    > One is displaying Categories and the other is displaying sub-categories.
    > When I click on a categorie in the first dropdownlist, I want the second
    > list to display
    > the sub-categories for the selected category.
    >
    > I tried it using the SelectedIndexChanged but this doesn't fire until a
    > submit of the page. Is there a way to have the desired effect whitout

    having
    > to perform a submit ?
    >
    > Thanks.
    >
    >
     
    Steve Willcock, Aug 9, 2004
    #2
    1. Advertising

  3. Bart Schelkens

    Mark Rae Guest

    "Steve Willcock" <> wrote in message
    news:cf7c9o$cvv$1$...

    The OP wrote:

    > Is there a way to have the desired effect whitout having to perform a

    submit ?

    And you replied:

    > Set the AutoPostBack property of the Categories drop down list to true


    :)
     
    Mark Rae, Aug 9, 2004
    #3
  4. Bart Schelkens

    Mark Rae Guest

    "Bart Schelkens" <> wrote in message
    news:...

    > Is there a way to have the desired effect whitout having to perform a

    submit ?

    Yes, but I'm going to get flamed for suggesting it :)

    But before I do, you must have a REALLY good reason for not performing a
    submit, because that is by far the best way to achieve what you want.

    However, if you really don't want to submit, and the datasets in question
    are relatively small, you could create a JavaScript client-side array in the
    <HEAD> of your page which contains all of the records in the related combo.
    Then, when the user selects a different option in the first combo, you call
    a client-side JavaScript function which clears the options from the second
    combo and repopulates it with only thos options which relate to the
    selection in the first combo.

    This is not a good idea for several reasons:

    1) The array is likely to be large, which will slow the initial load of your
    page.

    2) If a new option is added to the database, it will not be picked up until
    the page actually is refreshed.

    Don't do it unless there is a compelling reason to do so...
     
    Mark Rae, Aug 9, 2004
    #4
  5. Thx,

    the autopostback was just what i needed.

    "Steve Willcock" <> wrote in message
    news:cf7c9o$cvv$1$...
    > Set the AutoPostBack property of the Categories drop down list to true
    >
    > --
    > Steve Willcock, MCSD
    > http://www.willcockconsulting.com/
    >
    > "Bart Schelkens" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I have a webpage that contains 2 dropdownlists.
    > >
    > > One is displaying Categories and the other is displaying sub-categories.
    > > When I click on a categorie in the first dropdownlist, I want the second
    > > list to display
    > > the sub-categories for the selected category.
    > >
    > > I tried it using the SelectedIndexChanged but this doesn't fire until a
    > > submit of the page. Is there a way to have the desired effect whitout

    > having
    > > to perform a submit ?
    > >
    > > Thanks.
    > >
    > >

    >
    >
     
    Bart Schelkens, Aug 10, 2004
    #5
  6. Bart Schelkens

    Mark Rae Guest

    "Bart Schelkens" <> wrote in message
    news:...

    > the autopostback was just what i needed.


    So why did your OP ask:

    > Is there a way to have the desired effect whitout having to perform a

    submit ?

    ???
     
    Mark Rae, Aug 10, 2004
    #6
  7. Mark,

    the problem was that it only worked when i pushed a submit-button.
    And at some point during the refresh I lost the data that was in the
    dropdownlists.

    With the AutoPostBack it doesn't have that effect.

    Maybe I wasn't clear in my question. If so, sorry for that.

    "Mark Rae" <> wrote in message
    news:...
    > "Bart Schelkens" <> wrote in message
    > news:...
    >
    > > the autopostback was just what i needed.

    >
    > So why did your OP ask:
    >
    > > Is there a way to have the desired effect whitout having to perform a

    > submit ?
    >
    > ???
    >
    >
     
    Bart Schelkens, Aug 11, 2004
    #7
  8. Bart Schelkens

    Mark Rae Guest

    "Bart Schelkens" <> wrote in message
    news:...

    > the problem was that it only worked when i pushed a submit-button.
    > And at some point during the refresh I lost the data that was in the
    > dropdownlists.
    >
    > With the AutoPostBack it doesn't have that effect.
    >
    > Maybe I wasn't clear in my question. If so, sorry for that.


    That's no problem.
     
    Mark Rae, Aug 11, 2004
    #8
    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. Peter J. Hunter

    Positioning in dropdownlists

    Peter J. Hunter, Jan 14, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    519
    Peter J. Hunter
    Jan 14, 2004
  2. Craig Buchanan

    parent child dropdownlists acting oddly

    Craig Buchanan, Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    466
    Craig Buchanan
    Jun 27, 2003
  3. Darren

    Multiple DropDownLists

    Darren, Aug 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    412
    Steve C. Orr, MCSD
    Aug 18, 2003
  4. Colin Basterfield

    DropDownLists in XSLT

    Colin Basterfield, Dec 17, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    493
    Colin Basterfield
    Dec 17, 2003
  5. Craig Buchanan

    reuse SQLDataReader in multiple dropdownlists?

    Craig Buchanan, Jan 12, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,285
    Craig Buchanan
    Jan 15, 2004
Loading...

Share This Page