We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


gridview formatting - can you add blank rows

andieje asked
Medium Priority
Last Modified: 2012-08-13

I don't know much about the internal structure of data controls. How would you go about adding a blank row to a gridview to put some text in?

Thanks a lot
Watch Question


if you are using a gridview - you have to bind it to a data source to display the data...
can add a new row to the DataTable and then bind the grid to table, then set the gridview editindex to the new row,
      // Open Connection
      // New DataSet
      DataSet dbSet = new DataSet();
      // Populate DataSet with data
      dbAdapt.Fill(dbSet, "tblFile");

      // Get reference to our table
      DataTable dbTable = dbSet.Tables["tblFile"];

      // Create new row
      DataRow dbRow = dbTable.NewRow();

      // Store data in the row
      dbRow["FileName"] = "";
      dbRow["FileSize"] = '";

      // Add row back to table
                from here set the datasource   - idea is right just syntax errors
                gridview.datasource = dbTable.defaultview
                gridview.editindex = the index of the new row

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


You're kidding me??? Is this the easiest way to add a text row to a gridview? wow

is there a primary key value in the datagrid - does the new row need a primary key or auto increment index value? my way will make sure that if there is one then the new row will contain the new index, otherwise if it is not required then there is more could be a few other ways to do it.



I don't think i phrased my question very well. I don't mean a new row in the gridview for containing actual database data.

I meant, can you add a row to the gridview that is purely for display purposes, for example to comment on the dtaa that is being displayed.

My question is more about formatting the gridview control. I would like to be able to add extra blank spaces between rows of data where I can add information of my own, nothing to do with the underlying data source. In the spaces I would like to add titles/subtitles/comments.

Thanks a lot, andrea
hi andrea,

you could possibly do it with this javascript eg add cells to the table with client side scripting, I am not that clued up on javascripting but it would be a good idea to get upto spead on it as microsoft are going to push a technology called ajax which is basically asp.net with java doing client side stuff to minimise server requests and give the user a similiar experience to using a windows app, eg more functionality and more responsive...
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.