Multiple DropDownLists

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Igor

    Multiple DropDownLists

    Hello

    I have the following problem. I have three drop down lists on my page. They
    are filled with data from a database. Initially only the first one is
    enabled. The next one is enebled when user selects an item from the first
    one -- it is then filled with data specific to the selection in the drop
    down list above. The same with the third one. For each drop down list the
    first item is always "--select an item--" (as described here:
    http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To enable
    that I had to set the AppendDataBound Items property for all three drop down
    lists to "true". Unfortunatelly, when a user selects an item from the first
    drop down list, the second one gets filled with item "--select an item--"
    and data from the database. But if the user changes their mind and selects
    different item from the first list (or list above in the structure) the next
    drop down list gets filled with new data, but, because of the
    AppendDataBound Items property set to "true", previous data remains in the
    list. Thus, I must clear list(s) when user makes change to the selection
    above in the structure. How can I do this?

    Kind regards

    IgorM

  • David Wier

    #2
    Re: Multiple DropDownLists

    ddl.items.clear

    David Wier

    http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
    bloated markup


    "Igor" <igorm@live.com wrote in message
    news:22BA969D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
    Hello
    >
    I have the following problem. I have three drop down lists on my page.
    They are filled with data from a database. Initially only the first one is
    enabled. The next one is enebled when user selects an item from the first
    one -- it is then filled with data specific to the selection in the drop
    down list above. The same with the third one. For each drop down list the
    first item is always "--select an item--" (as described here:
    http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To enable
    that I had to set the AppendDataBound Items property for all three drop
    down lists to "true". Unfortunatelly, when a user selects an item from the
    first drop down list, the second one gets filled with item "--select an
    item--" and data from the database. But if the user changes their mind and
    selects different item from the first list (or list above in the
    structure) the next drop down list gets filled with new data, but, because
    of the AppendDataBound Items property set to "true", previous data remains
    in the list. Thus, I must clear list(s) when user makes change to the
    selection above in the structure. How can I do this?
    >
    Kind regards
    >
    IgorM

    Comment

    • Igor

      #3
      Re: Multiple DropDownLists

      Hi

      I didn't make myself clear enough. Where should I put it in the code ? I
      tried putting it in SelectedIndexCh anged events of particular drop down
      lists as well as PageLoad event but than I had a problem with a statement
      that selects first item (the one with "--select item --" text ) in the drop
      down lists below in the hierarchy because it fired exceptions. By
      ddl.items.clear the first item, the "--select item--" is also cleares, and
      it is not added again in postbacks.

      Kind regars
      IgorM

      "David Wier" <dw@dw.comwro te in message
      news:%23GwEyeJz IHA.2208@TK2MSF TNGP04.phx.gbl. ..
      ddl.items.clear
      >
      David Wier

      http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
      no bloated markup
      >
      >
      "Igor" <igorm@live.com wrote in message
      news:22BA969D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
      >Hello
      >>
      >I have the following problem. I have three drop down lists on my page.
      >They are filled with data from a database. Initially only the first one
      >is enabled. The next one is enebled when user selects an item from the
      >first one -- it is then filled with data specific to the selection in the
      >drop down list above. The same with the third one. For each drop down
      >list the first item is always "--select an item--" (as described here:
      >http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To enable
      >that I had to set the AppendDataBound Items property for all three drop
      >down lists to "true". Unfortunatelly, when a user selects an item from
      >the first drop down list, the second one gets filled with item "--select
      >an item--" and data from the database. But if the user changes their mind
      >and selects different item from the first list (or list above in the
      >structure) the next drop down list gets filled with new data, but,
      >because of the AppendDataBound Items property set to "true", previous data
      >remains in the list. Thus, I must clear list(s) when user makes change to
      >the selection above in the structure. How can I do this?
      >>
      >Kind regards
      >>
      >IgorM
      >
      >

      Comment

      • David Wier

        #4
        Re: Multiple DropDownLists

        You should put it anywhere you need it, in any event handler, just before
        you're populating the ddl.
        Anothere thing - if you're populating any ddls in the Page_Load event, be
        sure to surround that population with an if/then/Postback block

        David Wier

        http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
        bloated markup


        "Igor" <igorm@live.com wrote in message
        news:0D236198-A615-46CB-8100-F8982695CB8E@mi crosoft.com...
        Hi
        >
        I didn't make myself clear enough. Where should I put it in the code ? I
        tried putting it in SelectedIndexCh anged events of particular drop down
        lists as well as PageLoad event but than I had a problem with a statement
        that selects first item (the one with "--select item --" text ) in the
        drop down lists below in the hierarchy because it fired exceptions. By
        ddl.items.clear the first item, the "--select item--" is also cleares, and
        it is not added again in postbacks.
        >
        Kind regars
        IgorM
        >
        "David Wier" <dw@dw.comwro te in message
        news:%23GwEyeJz IHA.2208@TK2MSF TNGP04.phx.gbl. ..
        >ddl.items.clea r
        >>
        >David Wier
        >http://aspnet101.com
        >http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
        >no bloated markup
        >>
        >>
        >"Igor" <igorm@live.com wrote in message
        >news:22BA969 D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
        >>Hello
        >>>
        >>I have the following problem. I have three drop down lists on my page.
        >>They are filled with data from a database. Initially only the first one
        >>is enabled. The next one is enebled when user selects an item from the
        >>first one -- it is then filled with data specific to the selection in
        >>the drop down list above. The same with the third one. For each drop
        >>down list the first item is always "--select an item--" (as described
        >>here: http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To
        >>enable that I had to set the AppendDataBound Items property for all three
        >>drop down lists to "true". Unfortunatelly, when a user selects an item
        >>from the first drop down list, the second one gets filled with item
        >>"--select an item--" and data from the database. But if the user changes
        >>their mind and selects different item from the first list (or list above
        >>in the structure) the next drop down list gets filled with new data,
        >>but, because of the AppendDataBound Items property set to "true",
        >>previous data remains in the list. Thus, I must clear list(s) when user
        >>makes change to the selection above in the structure. How can I do this?
        >>>
        >>Kind regards
        >>>
        >>IgorM
        >>
        >>
        >

        Comment

        • Igor

          #5
          Re: Multiple DropDownLists

          Still don't know how to get the first item to be "--select value--" in code
          behind if I cannot use the <asp:ListItem Text="-- select value --"
          Value="">.


          "David Wier" <dw@dw.comwro te in message
          news:O8XAiRKzIH A.4492@TK2MSFTN GP02.phx.gbl...
          You should put it anywhere you need it, in any event handler, just before
          you're populating the ddl.
          Anothere thing - if you're populating any ddls in the Page_Load event, be
          sure to surround that population with an if/then/Postback block
          >
          David Wier

          http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
          no bloated markup
          >
          >
          "Igor" <igorm@live.com wrote in message
          news:0D236198-A615-46CB-8100-F8982695CB8E@mi crosoft.com...
          >Hi
          >>
          >I didn't make myself clear enough. Where should I put it in the code ? I
          >tried putting it in SelectedIndexCh anged events of particular drop down
          >lists as well as PageLoad event but than I had a problem with a statement
          >that selects first item (the one with "--select item --" text ) in the
          >drop down lists below in the hierarchy because it fired exceptions. By
          >ddl.items.clea r the first item, the "--select item--" is also cleares,
          >and it is not added again in postbacks.
          >>
          >Kind regars
          >IgorM
          >>
          >"David Wier" <dw@dw.comwro te in message
          >news:%23GwEyeJ zIHA.2208@TK2MS FTNGP04.phx.gbl ...
          >>ddl.items.cle ar
          >>>
          >>David Wier
          >>http://aspnet101.com
          >>http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
          >>with no bloated markup
          >>>
          >>>
          >>"Igor" <igorm@live.com wrote in message
          >>news:22BA96 9D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
          >>>Hello
          >>>>
          >>>I have the following problem. I have three drop down lists on my page.
          >>>They are filled with data from a database. Initially only the first one
          >>>is enabled. The next one is enebled when user selects an item from the
          >>>first one -- it is then filled with data specific to the selection in
          >>>the drop down list above. The same with the third one. For each drop
          >>>down list the first item is always "--select an item--" (as described
          >>>here: http://weblogs.asp.net/scottgu/archi...9/436804.aspx).
          >>>To enable that I had to set the AppendDataBound Items property for all
          >>>three drop down lists to "true". Unfortunatelly, when a user selects an
          >>>item from the first drop down list, the second one gets filled with
          >>>item "--select an item--" and data from the database. But if the user
          >>>changes their mind and selects different item from the first list (or
          >>>list above in the structure) the next drop down list gets filled with
          >>>new data, but, because of the AppendDataBound Items property set to
          >>>"true", previous data remains in the list. Thus, I must clear list(s)
          >>>when user makes change to the selection above in the structure. How can
          >>>I do this?
          >>>>
          >>>Kind regards
          >>>>
          >>>IgorM
          >>>
          >>>
          >>
          >
          >

          Comment

          • Mark Elliott

            #6
            Re: Multiple DropDownLists

            Would something like the following work?

            DropDownList ddl = new DropDownList();
            ListItem li = new ListItem("--select item--");
            ddl.Items.Inser t(li);

            On Thu, 12 Jun 2008 13:57:18 -0300, Igor <igorm@live.com wrote:
            Still don't know how to get the first item to be "--select value--" in
            code behind if I cannot use the <asp:ListItem Text="-- select value --"
            Value="">.
            >
            >
            "David Wier" <dw@dw.comwro te in message
            news:O8XAiRKzIH A.4492@TK2MSFTN GP02.phx.gbl...
            >You should put it anywhere you need it, in any event handler, just
            >before you're populating the ddl.
            >Anothere thing - if you're populating any ddls in the Page_Load event,
            >be sure to surround that population with an if/then/Postback block
            >>
            >David Wier
            >http://aspnet101.com
            >http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
            >with no bloated markup
            >>
            >>
            >"Igor" <igorm@live.com wrote in message
            >news:0D23619 8-A615-46CB-8100-F8982695CB8E@mi crosoft.com...
            >>Hi
            >>>
            >>I didn't make myself clear enough. Where should I put it in the code ?
            >>I tried putting it in SelectedIndexCh anged events of particular drop
            >>down lists as well as PageLoad event but than I had a problem with a
            >>statement that selects first item (the one with "--select item --"
            >>text ) in the drop down lists below in the hierarchy because it fired
            >>exceptions. By ddl.items.clear the first item, the "--select item--"
            >>is also cleares, and it is not added again in postbacks.
            >>>
            >>Kind regars
            >>IgorM
            >>>
            >>"David Wier" <dw@dw.comwro te in message
            >>news:%23GwEye JzIHA.2208@TK2M SFTNGP04.phx.gb l...
            >>>ddl.items.cl ear
            >>>>
            >>>David Wier
            >>>http://aspnet101.com
            >>>http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
            >>>with no bloated markup
            >>>>
            >>>>
            >>>"Igor" <igorm@live.com wrote in message
            >>>news:22BA969 D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
            >>>>Hello
            >>>>>
            >>>>I have the following problem. I have three drop down lists on my
            >>>>page. They are filled with data from a database. Initially only the
            >>>>first one is enabled. The next one is enebled when user selects an
            >>>>item from the first one -- it is then filled with data specific to
            >>>>the selection in the drop down list above. The same with the third
            >>>>one. For each drop down list the first item is always "--select an
            >>>>item--" (as described here:
            >>>>http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To
            >>>>enable that I had to set the AppendDataBound Items property for all
            >>>>three drop down lists to "true". Unfortunatelly, when a user selects
            >>>>an item from the first drop down list, the second one gets filled
            >>>>with item "--select an item--" and data from the database. But if
            >>>>the user changes their mind and selects different item from the
            >>>>first list (or list above in the structure) the next drop down list
            >>>>gets filled with new data, but, because of the AppendDataBound Items
            >>>>property set to "true", previous data remains in the list. Thus, I
            >>>>must clear list(s) when user makes change to the selection above in
            >>>>the structure. How can I do this?
            >>>>>
            >>>>Kind regards
            >>>>>
            >>>>IgorM
            >>>>
            >>>>
            >>>
            >>
            >>
            >


            --
            Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

            Comment

            • Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

              #7
              Re: Multiple DropDownLists

              Perhaps you can use this free control to make your life easier:
              Build web apps and services that run on Windows, Linux, and macOS using C#, HTML, CSS, and JavaScript. Get started for free on Windows, Linux, or macOS.


              --
              I hope this helps,
              Steve C. Orr,
              MCSD, MVP, CSM, ASPInsider
              HALOJP adalah situs slot online resmi terpercaya yang tawarkan akses gampang maxwin. Cukup depo 10k, nikmati ribuan game gacor dengan sistem aman dan pembayaran lancar.




              "Igor" <igorm@live.com wrote in message
              news:22BA969D-A3F0-4AF7-B786-EC9B40183279@mi crosoft.com...
              Hello
              >
              I have the following problem. I have three drop down lists on my page.
              They are filled with data from a database. Initially only the first one is
              enabled. The next one is enebled when user selects an item from the first
              one -- it is then filled with data specific to the selection in the drop
              down list above. The same with the third one. For each drop down list the
              first item is always "--select an item--" (as described here:
              http://weblogs.asp.net/scottgu/archi...9/436804.aspx). To enable
              that I had to set the AppendDataBound Items property for all three drop
              down lists to "true". Unfortunatelly, when a user selects an item from the
              first drop down list, the second one gets filled with item "--select an
              item--" and data from the database. But if the user changes their mind and
              selects different item from the first list (or list above in the
              structure) the next drop down list gets filled with new data, but, because
              of the AppendDataBound Items property set to "true", previous data remains
              in the list. Thus, I must clear list(s) when user makes change to the
              selection above in the structure. How can I do this?
              >
              Kind regards
              >
              IgorM

              Comment

              Working...