Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9136101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:54:32+00:00 2026-06-17T08:54:32+00:00

I encountered a problem in Gridview, I cannot merge the headers if the Gridview

  • 0

I encountered a problem in Gridview, I cannot merge the headers if the Gridview has no record, but if the Gridview contain a record, the headers are merging.

Here is my codes that I used to merge the headers in the Gridview

protected void grdWorkExperience_RowCreated(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.Header)
        {
            GridView oGridView = (GridView)sender;
            GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
            TableCell oTableCell = new TableCell();

            oTableCell.Text = string.Empty;
            oTableCell.ColumnSpan = 2;
            oTableCell.BorderColor = System.Drawing.Color.White;
            oGridViewRow.Cells.Add(oTableCell);

            oTableCell = new TableCell();
            oTableCell.Text = "Inclusive Dates(mm/dd/yyyy)";
            oTableCell.ColumnSpan = 2;
            oTableCell.Font.Bold = true;
            oTableCell.Font.Size = 9;
            oTableCell.Font.Name = "Verdana";
            oTableCell.HorizontalAlign = HorizontalAlign.Center;
            oTableCell.BackColor = System.Drawing.Color.FromArgb(0x33, 0x66, 0xCC);
            oTableCell.ForeColor = System.Drawing.Color.White;
            oTableCell.BorderColor = System.Drawing.Color.Gray;
            oGridViewRow.Cells.Add(oTableCell);

            oTableCell = new TableCell();
            oTableCell.BorderColor = System.Drawing.Color.White;
            oTableCell.ColumnSpan = 13;
            oGridViewRow.Cells.Add(oTableCell);

            oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);

        }
    }

I placed that function in onRowCreated event of Gridview

What should I do to merge the Headers even if the Gridview has no record?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:54:33+00:00Added an answer on June 17, 2026 at 8:54 am

    Move the code from OnRowCreated event to Load event of the Window/Control/Page

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered a problem in c++. I read some codes,but there was a very
I encountered a problem that took me too much time, but without resolving it.soI
I encountered a problem. I noticed that a Property (say MyProp ) in my
I encountered this problem. When I cannot assign a unicode string to models.CharField .
I encountered a problem here. I'm using C++ multiset. This is the test file.
I encountered this problem several times, so I m asking here what is the
I have encountered a problem. When I use jQuery to load a page that
I encountered similar problem if statement vs OO Design - 1 but it is
I encountered a problem that I can't solve. My point is to click my
I encountered a problem that I can't manage to save Excel start time and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.