gridview formatting - can you add blank rows

Hi

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
andrea
andiejeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deanvanrooyenCommented:
hi,

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,
eg
      // Open Connection
      dbConn.Open();
                              
      // 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
      dbTable.Rows.Add(dbRow);
               
                from here set the datasource   - idea is right just syntax errors
                gridview.datasource = dbTable.defaultview
                gridview.databind()
                gridview.editindex = the index of the new row
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andiejeAuthor Commented:
You're kidding me??? Is this the easiest way to add a text row to a gridview? wow
0
deanvanrooyenCommented:
hi,

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.
0
andiejeAuthor Commented:
Hi

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
0
deanvanrooyenCommented:
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...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.