ASP.NET: adding extra row to gridview


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?

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.

These articles can help you on your way

How To Customize Header Of ASP.Net DataGrid

How to Change DataGrid Header Text?
odubhgaillAuthor Commented:
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

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


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
Please close this question...
I answered my own question, what do I do?
Closed, 500 points refunded.
Community Support Moderator
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

From novice to tech pro — start learning today.