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 to add new row to gridview before fill it from datatable?

How to add new row to gridview before fill it from datatable?

Scheduled Pinned Locked Moved C#
tutorialquestion
6 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
    lamiaa_123
    wrote on last edited by
    #1

    I have agridview i fill it from datatable but i want to add new emptyrow af first before filling

    S 1 Reply Last reply
    0
    • L lamiaa_123

      I have agridview i fill it from datatable but i want to add new emptyrow af first before filling

      S Offline
      S Offline
      sanforjackass
      wrote on last edited by
      #2

      gridview.Rows.add("",""....); OR gridview.Rows.add(5);

      EASY COME EASY GO

      L 1 Reply Last reply
      0
      • S sanforjackass

        gridview.Rows.add("",""....); OR gridview.Rows.add(5);

        EASY COME EASY GO

        L Offline
        L Offline
        lamiaa_123
        wrote on last edited by
        #3

        i tried this gridview1.Rows.Add(); gridview1.DataSource = ds; this exception No row can be added to a DataGridView control that does not have columns. Columns must be added first.

        S 1 Reply Last reply
        0
        • L lamiaa_123

          i tried this gridview1.Rows.Add(); gridview1.DataSource = ds; this exception No row can be added to a DataGridView control that does not have columns. Columns must be added first.

          S Offline
          S Offline
          sanforjackass
          wrote on last edited by
          #4

          this exception No row can be added to a DataGridView control that does not have columns. Columns must be added first. so what do you think the problem??? how many col in your database? if 2 then for example: gridview1.columns.add("id","id"); gridview1.columns.add("name","name"); then try it if it did not work try to add them row by row

          EASY COME EASY GO

          L 1 Reply Last reply
          0
          • S sanforjackass

            this exception No row can be added to a DataGridView control that does not have columns. Columns must be added first. so what do you think the problem??? how many col in your database? if 2 then for example: gridview1.columns.add("id","id"); gridview1.columns.add("name","name"); then try it if it did not work try to add them row by row

            EASY COME EASY GO

            L Offline
            L Offline
            lamiaa_123
            wrote on last edited by
            #5

            Thank u sanforjackass thats help me alot.

            S 1 Reply Last reply
            0
            • L lamiaa_123

              Thank u sanforjackass thats help me alot.

              S Offline
              S Offline
              sanforjackass
              wrote on last edited by
              #6

              ;)

              EASY COME EASY GO

              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