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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ValueMember of comboBox problem

ValueMember of comboBox problem

Scheduled Pinned Locked Moved C#
helpdatabasequestion
4 Posts 2 Posters 1 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.
  • M Offline
    M Offline
    moonangel_bio
    wrote on last edited by
    #1

    Hi all, I’m using the comboBox to show values to select one of them Those values are from a database, where there are Ids and values. So, the DisplayMember is the value and the ValueMember is the ID. the first worked but the second refuses to work at all. And I don’t know why..? comboBox1.DataSource = dataSet3.Tables["DESIGNATION_EDIT"]; comboBox1.ValueMember = "D_ID"; comboBox1.DisplayMember = "D_TYPE"; then i need to use it here where the problem appears newrow[11]=comboBox1.ValueMember; table.Rows.Add(newrow); if any body could help.., I’ll be grateful.

    C 1 Reply Last reply
    0
    • M moonangel_bio

      Hi all, I’m using the comboBox to show values to select one of them Those values are from a database, where there are Ids and values. So, the DisplayMember is the value and the ValueMember is the ID. the first worked but the second refuses to work at all. And I don’t know why..? comboBox1.DataSource = dataSet3.Tables["DESIGNATION_EDIT"]; comboBox1.ValueMember = "D_ID"; comboBox1.DisplayMember = "D_TYPE"; then i need to use it here where the problem appears newrow[11]=comboBox1.ValueMember; table.Rows.Add(newrow); if any body could help.., I’ll be grateful.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      moonangel_bio wrote:

      hen i need to use it here where the problem appears newrow[11]=comboBox1.ValueMember; table.Rows.Add(newrow);

      what actually happens ? Christian Graus - Microsoft MVP - C++

      M 1 Reply Last reply
      0
      • C Christian Graus

        moonangel_bio wrote:

        hen i need to use it here where the problem appears newrow[11]=comboBox1.ValueMember; table.Rows.Add(newrow);

        what actually happens ? Christian Graus - Microsoft MVP - C++

        M Offline
        M Offline
        moonangel_bio
        wrote on last edited by
        #3

        when i try to add a new record using my application, this messeage appears: An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll Additional information: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToInt32(String value, IFormatProvider provider) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at System.Data.Common.Int32Storage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store in S_DESIGNATION_ID Column. Expected type is Int32. where D_ID is the ValueMember of the comboBox and i need it to be stored in S_DESIGNATION_ID in the data base

        C 1 Reply Last reply
        0
        • M moonangel_bio

          when i try to add a new record using my application, this messeage appears: An unhandled exception of type 'System.ArgumentException' occurred in system.data.dll Additional information: System.FormatException: Input string was not in a correct format. at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.Int32.Parse(String s, NumberStyles style, IFormatProvider provider) at System.Convert.ToInt32(String value, IFormatProvider provider) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at System.Data.Common.Int32Storage.Set(Int32 record, Object value) at System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store in S_DESIGNATION_ID Column. Expected type is Int32. where D_ID is the ValueMember of the comboBox and i need it to be stored in S_DESIGNATION_ID in the data base

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Well, now that you're told us the problem, it's obvious. A string that's coming in is not a number, and it needs to be. Christian Graus - Microsoft MVP - C++

          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