Adding a blank DataGridItem row or header row to a GridView object...

I really haven't seen any examples of adding a blank header row or item row to a GridView control....


Is there a way to do this?




5/2/2007 3:11:34 PM 72751 articles. 3 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 54

If you handle the RowCreated event then you can determine the row type (if it is header or data) and then reformat it or insert a row after or before it
Phillip Williams,
5/2/2007 4:37:08 PM

good article...


My scenario is one where I have over 15 columns, so I need to keep them aligned.  I found that when I implemented the solution provided, I lost the ability to keep all of my column names and columns aligned.

 Here is a screen shot of what I'm trying to accomplish:

Thanks again for your help...



5/3/2007 7:16:16 PM

good article...


My scenario is one where I have over 15 columns, so I need to keep them aligned.  I found that when I implemented the solution provided, I lost the ability to keep all of my column names and columns aligned.

 Here is a screen shot of what I'm trying to accomplish:


As you can see from the screen shot, I'm trying to add a row to the top of the grid view so that I can add some grouping images (lines, text) to indicate month's proven to be more difficult that I first imagined...unless I'm complicating it... 

Thanks again for your help...



5/3/2007 7:16:52 PM submitted twice..



5/3/2007 7:18:02 PM

Check out the example here:

It helped me a lot. Of course, you can work out better solutions than this one :)

Don't forget to mark solution providing post as "Answered".
It helps others to find correct solutions!

Also visit my ASP.NET blog!
5/3/2007 7:53:21 PM


 that works!


5/4/2007 3:25:30 PM

Similar Artilces:

adding a blank header row /row above the header row
is it possible to add a blank row above the header row in gridview for adding some links and buttons the links will respond to thae data in the grid and the buttons are for login / regisration etc....  if yes how it can be done or how do i achieve it. Its better that u create a table with a single row with columns matching the GridView columns. Set the table width same as the GridView width. This will make the GridView Look as if there is a row above its header.Please do not forget to click Mark As Answer on the post that helped you. Regards,Iam Srikanth Reddy....

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

Adding row (one at a time) in gridview on a button click. And cells of added row should contain controls like DROPDOWN LIST or TEXT BOX.
Dear Friends, I am in great need for the solution/hints/guidance of my requirement, if anyone can help with.  Let me explain what I need."I need a Gridview control on a webpage having following 5 columns/fields.     Column 1: It just has a "+" button in its header only (other cells for this column is empty)    Column 2: The Column header here is "FIELD" and  it should contain dropdown list (which is populated from some database)    Column 3: The Column header here is "Operator" and  it should ...

Hi all,I have a gridview and I have add an extra header row in RowCreated event.----------------------Code:Dim headerCell As TableCell = New TableCellDim rowHeader As GridViewRow = New GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal)headerCell.ColumnSpan = 3headerCell.Text = "Hello"rowHeader.Cells.Add(headerCell)grid.Controls(0).Controls.AddAt(0, rowHeader)----------------------.....row binding is ok, I can see everything correctly displayed........However, when I try to loop the rows in the grid, there is nothing in row=0 and what suppose to be in ro...

adding / deleting table rows, and accessing controls within added rows
Hi everyone,I would like to know what is a good and simple way to achieve this using  Basically i would like the ability to add and delete rows, preferably table rows.  Against each row is its delete button, hitting it will delete the corresponding row.  There is only 1 Add button to add a new row.  In each row, there are say 2 textboxes.  When i hit, say a calculate button, i wish to be able to access all the available textboxes in all the available rows in the event handler, and say just output a sum.If GridView is suggested, could you please explain why i...

Data Controls insert rows into gridview then insert rows from gridview into SQL Table
Hello there, I'm still new at performing miracles with code . Currently I am having trouble with my latest coding adventure I have a web application which records jobs and labour assigned to jobs. The issue in particular I'm having is the way in which labour is to be assigned. I want to use standard controls (Textbox, Dropdownlist) to record the values into a gridview (ie,put multiple rows into the gridview using the controls). Then, when all the inserting is complete, the user clicks a submit button to insert all the rows from the gridview into a database table. The reason for...

Adding a row to the last row column in Gridview ?
Hello, I have a gridview and it displays data in row column and I want to add a row across in the bottom of the last row for the total value.  How do I do it?  Thanks Here is my Gridview <Columns> <asp:BoundField DataField="Information" HeaderText="Information" SortExpression="Information" HeaderStyle-Width = "600" HeaderStyle-Wrap = "true"/> </Columns>   use footer? something like maybe.    use TemplateField   <Columns> <asp:BoundField DataField="Infor...

Adding blank rows to Gridview...
Okay - I just had an idea about my adding blank rows problem...please let me know if anyone knows if this is feasible: The GridView will have some dropdownlists that will be populated by connecting to a different ObjectDataSource, and depending on what criteria is selected in DDL's that are separate from the gridview (but must be selected before the girdview will allow data entry) there are some columns in the Gridview that should automatically populate with data (such as the State they're in.)  Since I will have this "data" to populate the Gridview with to ...

Gridview with multiple header rows
Hi, I have just installed the CSS Friendly Control Adapters and now my gridviews are not displaying dynamically added header rows. Code for adding rows is like so: Dim headerCell As New TableHeaderCellheaderCell.ColumnSpan = gridview.Columns.Count headerCell.Text = headingDim rowHeader As New GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal) rowHeader.Controls.Add(headerCell) CType(gridview.Controls(0), Table).Rows.AddAt(0, rowHeader)   This is typically used for adding a nicely formatted heading row and it is a requirment that i must have this extr...

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

keep adding blank rows to gridview
Is it possible to add a row to gridview upon run time? I have a grid that displays data. What I would like to do is allow the user to add new records to the grid and they can do it as long as they want. Is it even possible?Consistency + Intensity = Success You mean something like this? Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET Hi Vinz,            ...

Adding a new blank row to the a GridView
I would like to allow users to add new rows directly into the GridView control.  I have seen the articles on how to use the footer template to accomplish this... but there are times I need to use the footer for totals - and I would like to avoid having to duplicate my field validations controls in the edit and footer templates.When the user presses the 'NEW' button, I would like to pull up a blank row in edit mode.  I understand that I can send the blank row from my data object, but I would rather handle it on the page if possible.  I am not sure if I need to access the GridVi...

Adding blank rows to the end of a GridView...
I know - I've been searching Google for info on how to programmatically add rows to the end of a gridview - and found that this is a real pain to do what I am supposed to do.  Which is, add multiple rows to the end of a gridview after a user has entered a few rows.  I've found the "work-around" to add one row at a time using the GridView Footer, but our application (currently using a third party control - and knowing that the datagrid allowed you to add multiple blank rows) has a button that the user clicks to add ten rows at a time.  This is what the user wa...

Adding a blank row to the top of gridview
I use to have this code in , but seem to have lost it and now I can't seem to get it...  I want to have a button that when selected adds a blank row to the TOP of the gridview in edit mode so that I can insert (via update) a new row naturally by changing text fields and hitting a custom command. The blank row won't actually be in the data, just in the grid.  I'm trying this and it's not working failing at the bind. Protected Sub Insert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insert.Click Dim tbl As Table tbl = CType(ROLEMAINT.Contro...

Web resources about - Adding a blank DataGridItem row or header row to a GridView object... -

Fully Editable Datagrid - Pale Musings
This is the text from an article I wrote back in April of 2003 and had published on the original DotNetJunkies site. After my recent change in ...

Resources last updated: 12/5/2015 4:52:26 PM