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 do I get the value a cell in a datagrid

How do I get the value a cell in a datagrid

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 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.
  • W Offline
    W Offline
    Walaza
    wrote on last edited by
    #1

    Hi, I would like to get the value of a cell in a datagrid. I tried the ff code but it gave me an error: string value = dgOutput.CurrentCell.Value.ToString(); Please help.

    Mvelo Walaza Developer Telkom SA

    M E 2 Replies Last reply
    0
    • W Walaza

      Hi, I would like to get the value of a cell in a datagrid. I tried the ff code but it gave me an error: string value = dgOutput.CurrentCell.Value.ToString(); Please help.

      Mvelo Walaza Developer Telkom SA

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

      What was the error? Maybe check to see if the currentcell value is null? string value; if(dgOutput.CurrentCell.Value == null) { value = "null"; } else { value = dgOutput.CurrentCell.Value.ToString(); }

      1 Reply Last reply
      0
      • W Walaza

        Hi, I would like to get the value of a cell in a datagrid. I tried the ff code but it gave me an error: string value = dgOutput.CurrentCell.Value.ToString(); Please help.

        Mvelo Walaza Developer Telkom SA

        E Offline
        E Offline
        Eslam Afifi
        wrote on last edited by
        #3

        If you want to access a cell other than the currently selected

        dgOutput.Rows[rowindex].Cells[columnindexORname]
        

        Eslam Afifi

        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