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. How can I show custom string such as "N/A" in DataGrid instead (null) for null columns?

How can I show custom string such as "N/A" in DataGrid instead (null) for null columns?

Scheduled Pinned Locked Moved C#
question
2 Posts 1 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.
  • B Offline
    B Offline
    Behzad Ebrahimi
    wrote on last edited by
    #1

    How can I show custom string such as "N/A" in DataGrid instead (null) for null columns? My datagrid data will load by a DataSource. Or how can I filter sum record/field when loading fata from DataSource to DataGrid !? Thank you

    B 1 Reply Last reply
    0
    • B Behzad Ebrahimi

      How can I show custom string such as "N/A" in DataGrid instead (null) for null columns? My datagrid data will load by a DataSource. Or how can I filter sum record/field when loading fata from DataSource to DataGrid !? Thank you

      B Offline
      B Offline
      Behzad Ebrahimi
      wrote on last edited by
      #2

      I found it ...:suss: int nColCount = dataGrid1.DataSource.Tables[0].Columns.Count; int nStyleCount = dataGrid1.TableStyles.Count; for(int nSC= 0; nSC < nStyleCount; nSC++ ) for(int nCol = 0; nCol < nColCount; nCol++ ) { dataGrid1.TableStyles[nSC].GridColumnStyles[nCol].NullText = "N/A"; }

      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