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. Problems binding a dataset to a combobox

Problems binding a dataset to a combobox

Scheduled Pinned Locked Moved C#
csharpvisual-studiowpfwcfxml
5 Posts 4 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
    Jefferys
    wrote on last edited by
    #1

    I just can't seam to figure out why the following code is not working. I would be thankful for any help. Thanks, JefferyS :( CODE: string folderPath = "C:\\My Documents\\Visual Studio Projects\\MyDroidEngineer\\Data\\"; DataSet myDS = new DataSet(); myDS.ReadXml(folderPath + "planets.xml"); cboPlanets.DataSource = myDS.Tables["planet"]; cboPlanets.DisplayMember = "description"; cboPlanets.ValueMember = "swgcraft_id"; I get no errors and just a blank combo box I have used a temp datagrid to check the dataset and it displays correctly. Top Part of XML File: Corellia Dantooine Dathomir

    M S J 3 Replies Last reply
    0
    • J Jefferys

      I just can't seam to figure out why the following code is not working. I would be thankful for any help. Thanks, JefferyS :( CODE: string folderPath = "C:\\My Documents\\Visual Studio Projects\\MyDroidEngineer\\Data\\"; DataSet myDS = new DataSet(); myDS.ReadXml(folderPath + "planets.xml"); cboPlanets.DataSource = myDS.Tables["planet"]; cboPlanets.DisplayMember = "description"; cboPlanets.ValueMember = "swgcraft_id"; I get no errors and just a blank combo box I have used a temp datagrid to check the dataset and it displays correctly. Top Part of XML File: Corellia Dantooine Dathomir

      M Offline
      M Offline
      mikker_123
      wrote on last edited by
      #2

      Only thing I can suggest you with the code && info you gave is to try with: // cboPlanets.DataSource = myDS; cboPlanets.DisplayMember = "planet.description"; cboPlanets.ValueMember = "planet.swgcraft_id"; // Instead of what you wrote for those tree lines. If that doesn't solve drop solution somewhere and give link or give more info ;) c-ya

      S 1 Reply Last reply
      0
      • M mikker_123

        Only thing I can suggest you with the code && info you gave is to try with: // cboPlanets.DataSource = myDS; cboPlanets.DisplayMember = "planet.description"; cboPlanets.ValueMember = "planet.swgcraft_id"; // Instead of what you wrote for those tree lines. If that doesn't solve drop solution somewhere and give link or give more info ;) c-ya

        S Offline
        S Offline
        softp_vc
        wrote on last edited by
        #3

        I have seen the problem and hope following would work cboPlanet.DataSource=DS.Tables[0]; cmboPlanet.DisplayMember="description"; in place of the table name put its index no here (0). Naveen

        1 Reply Last reply
        0
        • J Jefferys

          I just can't seam to figure out why the following code is not working. I would be thankful for any help. Thanks, JefferyS :( CODE: string folderPath = "C:\\My Documents\\Visual Studio Projects\\MyDroidEngineer\\Data\\"; DataSet myDS = new DataSet(); myDS.ReadXml(folderPath + "planets.xml"); cboPlanets.DataSource = myDS.Tables["planet"]; cboPlanets.DisplayMember = "description"; cboPlanets.ValueMember = "swgcraft_id"; I get no errors and just a blank combo box I have used a temp datagrid to check the dataset and it displays correctly. Top Part of XML File: Corellia Dantooine Dathomir

          S Offline
          S Offline
          Shailendra Rao
          wrote on last edited by
          #4

          I think you need to call DataBind() method of the combobox after setting the properties.

          1 Reply Last reply
          0
          • J Jefferys

            I just can't seam to figure out why the following code is not working. I would be thankful for any help. Thanks, JefferyS :( CODE: string folderPath = "C:\\My Documents\\Visual Studio Projects\\MyDroidEngineer\\Data\\"; DataSet myDS = new DataSet(); myDS.ReadXml(folderPath + "planets.xml"); cboPlanets.DataSource = myDS.Tables["planet"]; cboPlanets.DisplayMember = "description"; cboPlanets.ValueMember = "swgcraft_id"; I get no errors and just a blank combo box I have used a temp datagrid to check the dataset and it displays correctly. Top Part of XML File: Corellia Dantooine Dathomir

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

            Thanks for all the suggestions. I figured out what was wrong and it wasn't the code. You can't set the sorted property on the combobox to true when using a dataset. I don't know why it didn't give me an exception error. I hope my folly helps someone not spend hours and hours trying to figure out why it was not working. Thanks again for all the help. Thanks, JefferyS :-D

            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