when i try to convert a value member to int32 says wrong data type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isitha
    New Member
    • Dec 2010
    • 9

    when i try to convert a value member to int32 says wrong data type

    Code:
    String empID = cmbEmp.ValueMember.ToString();
    int empIDint = Convert.ToInt16(empID);
    This`s the error i get "Input string was not in a correct format."
    "when converting a string to date time, parse the string to take the date before putting each variable into the datetime object....."

    guyz i dont understand what to do now...
  • EARNEST
    New Member
    • Feb 2010
    • 128

    #2
    Try this

    Code:
    int empIDint = Int32.Parse(cmbEmp.ValueMember.ToString());
    hope it helps

    Comment

    • isitha
      New Member
      • Dec 2010
      • 9

      #3
      to EARNEST

      thnx EARNEST....i think da problem is with my database table....bt still i cudn`t get it resolved....thn x agn

      Comment

      • Christian Binder
        Recognized Expert New Member
        • Jan 2008
        • 218

        #4
        Normally ValueMember is the name of the field/column, the values of the ComboBox are bound. I think you want to use the value of the currently selected item, so try
        Code:
        int empIDint = Convert.ToInt16(cmbEmp.SelectedValue);

        Comment

        • isitha
          New Member
          • Dec 2010
          • 9

          #5
          thnx CHRISTIAN it worked pretty well n i ve made some changes to my DB also......hav a gud day..

          Comment

          Working...