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

datatable

Scheduled Pinned Locked Moved C#
design
3 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.
  • F Offline
    F Offline
    fmardani
    wrote on last edited by
    #1

    Several combo boxes on the UI winform are populated using a DataTable. ie. dtUsers dtUsers is a table in a dataset. Several combo boxes are populated using this datatable. Not sure why when an item in one of the combo boxes is selected, then all the other combo boxes get changed too. This is a sample of how the combo boxes are populated: dtUsers = dsUsers.Tables["Users"]; cbo1.DataSource = dtUsers; cbo1.DisplayMember = "Name"; cbo1.ValueMember = "UserID";

    R N 2 Replies Last reply
    0
    • F fmardani

      Several combo boxes on the UI winform are populated using a DataTable. ie. dtUsers dtUsers is a table in a dataset. Several combo boxes are populated using this datatable. Not sure why when an item in one of the combo boxes is selected, then all the other combo boxes get changed too. This is a sample of how the combo boxes are populated: dtUsers = dsUsers.Tables["Users"]; cbo1.DataSource = dtUsers; cbo1.DisplayMember = "Name"; cbo1.ValueMember = "UserID";

      R Offline
      R Offline
      robmays
      wrote on last edited by
      #2

      I have had the same problem and solved it by using different datasources and not binding all combo boxes to the same datasource. So change this line dtUsers = dsUsers.Tables["Users"]; to another source

      1 Reply Last reply
      0
      • F fmardani

        Several combo boxes on the UI winform are populated using a DataTable. ie. dtUsers dtUsers is a table in a dataset. Several combo boxes are populated using this datatable. Not sure why when an item in one of the combo boxes is selected, then all the other combo boxes get changed too. This is a sample of how the combo boxes are populated: dtUsers = dsUsers.Tables["Users"]; cbo1.DataSource = dtUsers; cbo1.DisplayMember = "Name"; cbo1.ValueMember = "UserID";

        N Offline
        N Offline
        Nader Elshehabi
        wrote on last edited by
        #3

        I assume of course that in cbo2 you give the DisplayMember a different value, right? Try to make a break point to see if this value applies or not. Anyway, I've been working with ADO .Net and databindings for quite a while now, and let me tell you I'm completely displeased with it. It has many bugs, and what would Microsoft would call "features" that costed me a lot of time to discover it. When I submitted somehting to them all they said was "Make your own workaround. We don't have the time to fix this in the next version of Visual Studio. Thank you!", and that's it. Anyway. A good way -that works for me- is to use a BindingSource and bind it to your controls using cbo1.DataBindings.Add() method. It works fine fr the Text property -but not with CheckBox.Checked property BTW-. A sample would be

        BindingSource UsersSource = new BindingSource();
        UsersSource.DataSource = dsUsers.Tables["Users"];
        cbo1.DataBindings.Add(new Binding("SelectedItem", UsersSource, "Name"));
        cbo1.DataBindings.Add(new Binding("SelectedValue", UsersSource, "UseID"));

        I hope it works for you!:) -- modified at 6:55 Thursday 4th January, 2007 The above code I use for a DropDownList combobox. You can also bind to the Text property according to your need.

        Regards:rose:

        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