Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

In Nested Gridview, The Parent Gridview should pass an Id to Child GridView. The Child Gridview should display data with Multi Header(header then sub header).

Anybody having an idea.

Help Pl.

Thanks

Praveena
Posted

1 solution

Hi,

For nested grid display query have a look on the following link

http://mosesofegypt.net/post/2008/02/24/Building-a-grouping-Grid-with-GridView-and-ASPNET-AJAX-toolkit-CollapsiblePanel.aspx[^]


To have multiple headers in your grid try the following code.


protected void gvEmployee_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 = "Employee Details";
                oTableCell.ColumnSpan = 9;
                oGridViewRow.Cells.Add(oTableCell);
                oTableCell.CssClass = "header";
               
                oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
            }
        }


if you want a header like as follows.

Deparments
X Y Z


then


protected void gvEmployee_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 = "Departments";
                oTableCell.ColumnSpan = 3;
                oGridViewRow.Cells.Add(oTableCell);
                oTableCell.CssClass = "header";
               
                oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
            }
        }


Hope this helps.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900