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. Looping through a datagrid

Looping through a datagrid

Scheduled Pinned Locked Moved C#
helpdatabasequestion
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.
  • S Offline
    S Offline
    scotlandc
    wrote on last edited by
    #1

    Hi, I know its last thing on a Friday but I hope someone can help. I need to loop through every cell in a datagridview and make sure that each value is not null. Looping through the cells isn't a problem (I don't think), I used a for loop with another nested inside, the inner loop taking care of the column index and the outer loop holding the row index. What I can't do is check the contents of each cell as there is no suitable method in DataGridCell. Please can anyone help? Thanks Scott The loop code used if anyone is interested. for (int i = 0; i <= rowCount; i++) { for (int j = 0; j <= colCount; j++) { DataGridCell dgc = new DataGridCell(i, j); } } Scott

    P 1 Reply Last reply
    0
    • S scotlandc

      Hi, I know its last thing on a Friday but I hope someone can help. I need to loop through every cell in a datagridview and make sure that each value is not null. Looping through the cells isn't a problem (I don't think), I used a for loop with another nested inside, the inner loop taking care of the column index and the outer loop holding the row index. What I can't do is check the contents of each cell as there is no suitable method in DataGridCell. Please can anyone help? Thanks Scott The loop code used if anyone is interested. for (int i = 0; i <= rowCount; i++) { for (int j = 0; j <= colCount; j++) { DataGridCell dgc = new DataGridCell(i, j); } } Scott

      P Offline
      P Offline
      Private_Void
      wrote on last edited by
      #2

      Are you looking for something like this... grvMain.Rows[0].Cells[1].Text; I hope this helps. I have worked quited a bit with gridviews so let me know if I misunderstood your question. If you have controls you are attempting to check in the cells it should look more like this... ((TextBox)GridView1.Rows[1].FindControl("txtProviderID")).Text. Regards

      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