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

  • Home
  • SEARCH
  • 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 3403358
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:15:06+00:00 2026-05-18T05:15:06+00:00

How can I create below type of gridview with merge merged header columns? If

  • 0

How can I create below type of gridview with merge merged header columns? If anybody have example share with me.

alt text

Thanks in advance.

  • 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-05-18T05:15:06+00:00Added an answer on May 18, 2026 at 5:15 am

    Code for GridView

    <asp:GridView ID="grvMergeHeader" runat="server"
                  BackColor="LightGoldenrodYellow"
                  BorderColor="Tan" BorderWidth="5px"
                  CellPadding="3" ForeColor="Black"
                  GridLines="None" BorderStyle="None"
                  CellSpacing="2"
                  AutoGenerateColumns="False"
                  DataSourceID="SqlDataSource1"
                  OnRowCreated="grvMergeHeader_RowCreated">
        <FooterStyle BackColor="Tan" />
        <SelectedRowStyle BackColor="DarkSlateBlue"
                          ForeColor="GhostWhite" />
        <PagerStyle BackColor="PaleGoldenrod"
                    ForeColor="DarkSlateBlue"
                    HorizontalAlign="Center" />
        <HeaderStyle BackColor="Tan" Font-Bold="True" />
        <AlternatingRowStyle BackColor="PaleGoldenrod" />
        <Columns>
            <asp:BoundField DataField="DepartMentID"
                            HeaderText="DepartMentID"
                            SortExpression="DepartMentID" />
            <asp:BoundField DataField="DepartMent"
                            HeaderText="DepartMent"
                            SortExpression="DepartMent" />
            <asp:BoundField DataField="Name"
                            HeaderText="Name"
                            SortExpression="Name" />
            <asp:BoundField DataField="Location"
                            HeaderText="Location"
                            SortExpression="Location" />
        </Columns>
    </asp:GridView>
    

    CS Code

    //row created
    protected void grvMergeHeader_RowCreated(object sender, GridViewRowEventArgs e) {
        if (e.Row.RowType == DataControlRowType.Header) {
            GridView HeaderGrid = (GridView)sender;
            GridViewRow HeaderGridRow = new GridViewRow(0, 0, DataControlRowType.Header, 
                                                        DataControlRowState.Insert);  //creating new Header Type 
            TableCell HeaderCell = new TableCell(); //creating HeaderCell
            HeaderCell.Text = "Department";
            HeaderCell.ColumnSpan = 2;
            HeaderGridRow.Cells.Add(HeaderCell);//Adding HeaderCell to header.
    
            HeaderCell = new TableCell();
            HeaderCell.Text = "Employee";
            HeaderCell.ColumnSpan = 2;
            HeaderGridRow.Cells.Add(HeaderCell);
    
            grvMergeHeader.Controls[0].Controls.AddAt(0, HeaderGridRow);
        }
    }
    

    I hope this will work for you.

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

Sidebar

Related Questions

I have an interesting conundrum. I can create the type of chart I seek
Bitmap In the code below we can create it or it is one type
Can anyone tell how correct the following code below. Iam tryin to create a
The trigger below is delaying my insert response. How can I prevent this? create
How can I get only unique departments from the below example? Dept Id Created
How can I create an xsd to give me this type of xml structure
I couln't create a new data type on MySQL. Query is given below CREATE
With the code below, I created 1 border (white). How can I create another
Can anyone point me to an example of how to programatically create a statechart
The FluentAPI can not create a relational model based on the code below: public

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.