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. Web Development
  3. ASP.NET
  4. Add a Blank Row to Gridview?

Add a Blank Row to Gridview?

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netquestion
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.
  • B Offline
    B Offline
    BORN again
    wrote on last edited by
    #1

    Hello, Does anyone have a code snippet for adding a blank row at the end or top of the gridview on a button click?The button is outside the GV and not in the footer. I did it in datagrid and I guess it was easier.But for gridview it isn't working. I will post my little snippet but it is giving me error: Protected Sub btnadddriver_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadddriver.Click DriverGV.DataBind() Dim ds As DataSet = DriverGV.DataSource Dim blank As System.Data.DataRow = ds.Tables(0).NewRow() ds.Tables(0).Rows.InsertAt(blank, ds.Tables(0).Rows.Count) DriverGV.EditIndex = ds.Tables(0).Rows.Count - 1 DriverGV.DataBind() End Sub The error I am getting is : Exception Details: System.NullReferenceException: Object reference not set to an instance of an object Line 16: Dim blank As System.Data.DataRow = ds.Tables(0).NewRow() If someone has a working snippet for adding a blank row to the gridview can you kindly help me? I'm on Visual Studio2005,Asp.Net2.0,VB Thanks.All help is much appreciated.

    Aartee. ...HE is watching Us All!

    E 1 Reply Last reply
    0
    • B BORN again

      Hello, Does anyone have a code snippet for adding a blank row at the end or top of the gridview on a button click?The button is outside the GV and not in the footer. I did it in datagrid and I guess it was easier.But for gridview it isn't working. I will post my little snippet but it is giving me error: Protected Sub btnadddriver_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadddriver.Click DriverGV.DataBind() Dim ds As DataSet = DriverGV.DataSource Dim blank As System.Data.DataRow = ds.Tables(0).NewRow() ds.Tables(0).Rows.InsertAt(blank, ds.Tables(0).Rows.Count) DriverGV.EditIndex = ds.Tables(0).Rows.Count - 1 DriverGV.DataBind() End Sub The error I am getting is : Exception Details: System.NullReferenceException: Object reference not set to an instance of an object Line 16: Dim blank As System.Data.DataRow = ds.Tables(0).NewRow() If someone has a working snippet for adding a blank row to the gridview can you kindly help me? I'm on Visual Studio2005,Asp.Net2.0,VB Thanks.All help is much appreciated.

      Aartee. ...HE is watching Us All!

      E Offline
      E Offline
      enjoycrack
      wrote on last edited by
      #2

      Hi there: This article NewRowGridView might help you... << >>

      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