Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Populating ComboBox with "ALL" option

Populating ComboBox with "ALL" option

Scheduled Pinned Locked Moved C#
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jimish1
    wrote on last edited by
    #1

    Hi, I have a combo box which I am populating dynamically using Datatables. The combobox acts as a selection point from where a user selects a value and accordingly charts are generated..! The column i am populating changes dynamically and is never the same. Now I want to add another option "ALL" in the combo box after/before I populate the combobox...such that my combo box should have all the values frm table as well as an item " ALL " I tried doing it, but it shows error. Can anyone help me out please. how should i go abt it..? I am making a Windows Application using C#. Cheers

    Jimish

    N S 2 Replies Last reply
    0
    • J jimish1

      Hi, I have a combo box which I am populating dynamically using Datatables. The combobox acts as a selection point from where a user selects a value and accordingly charts are generated..! The column i am populating changes dynamically and is never the same. Now I want to add another option "ALL" in the combo box after/before I populate the combobox...such that my combo box should have all the values frm table as well as an item " ALL " I tried doing it, but it shows error. Can anyone help me out please. how should i go abt it..? I am making a Windows Application using C#. Cheers

      Jimish

      N Offline
      N Offline
      Noah Wollowick
      wrote on last edited by
      #2

      One thing you could do is to modify the SQL query so that 'ALL' is in the datatable. I.e. " SELECT Value1 FROM Table1 UNION ALL SELECT 'ALL' " Then the option value will be in the datatable and you can select it.

      J 1 Reply Last reply
      0
      • N Noah Wollowick

        One thing you could do is to modify the SQL query so that 'ALL' is in the datatable. I.e. " SELECT Value1 FROM Table1 UNION ALL SELECT 'ALL' " Then the option value will be in the datatable and you can select it.

        J Offline
        J Offline
        jimish1
        wrote on last edited by
        #3

        Query input must contain at least one table or query. It shows the above error..!

        Jimish

        1 Reply Last reply
        0
        • J jimish1

          Hi, I have a combo box which I am populating dynamically using Datatables. The combobox acts as a selection point from where a user selects a value and accordingly charts are generated..! The column i am populating changes dynamically and is never the same. Now I want to add another option "ALL" in the combo box after/before I populate the combobox...such that my combo box should have all the values frm table as well as an item " ALL " I tried doing it, but it shows error. Can anyone help me out please. how should i go abt it..? I am making a Windows Application using C#. Cheers

          Jimish

          S Offline
          S Offline
          Sun Rays
          wrote on last edited by
          #4

          Hi, After binding your datatable / dataset to Combobox. Add below line. cmBOX.Items.Insert(0,"ALL");

          Thanks, Sun Rays To get something you must have to try once. My Articles

          J 1 Reply Last reply
          0
          • S Sun Rays

            Hi, After binding your datatable / dataset to Combobox. Add below line. cmBOX.Items.Insert(0,"ALL");

            Thanks, Sun Rays To get something you must have to try once. My Articles

            J Offline
            J Offline
            jimish1
            wrote on last edited by
            #5

            I had tried it earlier..but it shows the following error..: Items collection cannot be modified when the DataSource property is set.

            Jimish

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups