We help IT Professionals succeed at work.

ASP.NET: adding extra row to gridview

odubhgaill
odubhgaill asked
on
Hi,

I have a gridview displaying product and price info. I want to display two header rows at the top of the gridview which will display category info etc. I need these header rows to be part of the gridview to maintain a consistent disaplay.

How can I add these 2 header rows and be able to set their text dynamically?

Robert
Comment
Watch Question

Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
These articles can help you on your way

How To Customize Header Of ASP.Net DataGrid
http://www.netomatix.com/DGHeader.aspx

How to Change DataGrid Header Text?
http://www.c-sharpcorner.com/UploadFile/sd_patel/DataGridHeaderText11232005050843AM/DataGridHeaderText.aspx
thanks for the input.

I found the solution elsewhere.

For reference - to add extra rows to the header of a gridview -

Protected Sub grdSelect_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdSelect.RowCreated

If e.Row.RowType = DataControlRowType.Header Then

            Dim row As GridViewRow
            Dim tableCell As TableCell


            row = New GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Insert)

            tableCell = New TableCell()
            tableCell.Text = "enter text here"
            tableCell.ColumnSpan = 3
            row.Cells.Add(tableCell)

            grdSelect.Controls(0).Controls.AddAt(0, row)

etc....
Dirk HaestProject manager
CERTIFIED EXPERT

Commented:
Please close this question...
See:
I answered my own question, what do I do?
http://www.experts-exchange.com/help.jsp#hi333

Commented:
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.