This is a migrated thread and some comments may be shown as answers.

Multiple Header Rows for RadGrid!

1 Answer 460 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MAXX
Top achievements
Rank 1
MAXX asked on 05 Mar 2010, 11:15 AM
Hi,

I generally use Asp.Net Gridview. In these grid i use to add multiple Header rows on Runtime by using "OnRowCreated" Event of the grid.

-----ASP.Net HTML code
 <asp:GridView ID="gv" runat="server" AllowSorting="False" AutoGenerateColumns="False"
                                        Width="350px" UseAccessibleHeader="False"
                                        OnRowDataBound="gv_RowDataBound" OnRowCreated="gv_RowCreated">

---------In Event

protected void gv_RowCreated(object sender, GridViewRowEventArgs e)
    {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                //Header row 1

                GridViewRow headerRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);

                headerRow.Cells.Add(CreateHeaderCell("Col1", "TestCol1", 1, 2,50)); 
                headerRow.Cells.Add(CreateHeaderCell("Col2", "TestCol2", 1, 1,50)); 

                ((GridView)sender).Controls[0].Controls.AddAt(0, headerRow);
               
                //e.Row.Visible = false; //for hiding Normal header row if needed
            }
    }
-------------------- Method for creating a Header cell
 public static TableCell CreateHeaderCell(string text, string tooltipText, int columnSpan, int rowSpan, int colWidth)
        {
            TableHeaderCell headerCell = new TableHeaderCell();
            headerCell.Text = text;
            headerCell.ToolTip = tooltipText;
            headerCell.ColumnSpan = columnSpan;
            headerCell.RowSpan = rowSpan;
            headerCell.Style.Add("text-align", "center");
            headerCell.Font.Bold = false;

            if (colWidth > 0)
            {
                headerCell.Width = colWidth;
            }
            return headerCell;
        }
--------------------------------------------------

Is it also possible to do same with Rad Grid?

Thanks in advance,
Ankur Mittal

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Mar 2010, 12:11 PM
Hello Ankur Mittal,

Checkout the following forum link which discusses similar scenario.

Thanks,
Princy.
Tags
Grid
Asked by
MAXX
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or