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. changing a column type of datagridview ?

changing a column type of datagridview ?

Scheduled Pinned Locked Moved C#
helpquestioncsharpwinformstutorial
2 Posts 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    hi all, i have a datagridview with 2 columns. one is StuID and the other is TermGrade. both are number fields. example: StuID TermGrade ----- --------- 2000 90 2001 80 2002 70 AVG: 80 i want to add a new row. which should contain the last row above. (AVG: under StuID field and 80 under TermGrade field) for TermGrade field everything is fine. cos it is a NUMBER field and i add a number in that cell. but for StuID field, i get type mismatch error since i try to add a STRING into NUMBER field. how can i get rid of this error ? is there a way to insert such a string (AVG:) to a number field ? help please, thanks in advance. bye. ps: how can i use footer in datagridview in windows forms with C# ? is possible to do what i want above with footer ?

    M 1 Reply Last reply
    0
    • L Lost User

      hi all, i have a datagridview with 2 columns. one is StuID and the other is TermGrade. both are number fields. example: StuID TermGrade ----- --------- 2000 90 2001 80 2002 70 AVG: 80 i want to add a new row. which should contain the last row above. (AVG: under StuID field and 80 under TermGrade field) for TermGrade field everything is fine. cos it is a NUMBER field and i add a number in that cell. but for StuID field, i get type mismatch error since i try to add a STRING into NUMBER field. how can i get rid of this error ? is there a way to insert such a string (AVG:) to a number field ? help please, thanks in advance. bye. ps: how can i use footer in datagridview in windows forms with C# ? is possible to do what i want above with footer ?

      M Offline
      M Offline
      MCSD Gandalf
      wrote on last edited by
      #2

      Seems to me the easiest solution is to make the first column a STRING. All you are doing is using it for displaying data anyway. Verify that it is a valid value, convert it to a string for display in the datagrid. If you need to pull it out, all you have to do is cast it back to whatever numeric datatype you are using. HTH Gandalf

      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