Subheader (subcolumns)

Discussion in 'ASP .Net Datagrid Control' started by Tumurbaatar S., Nov 20, 2005.

  1. Can anybody help me to make my DataGrid header
    like below one?
    --------------------------------------
    | | | SomeText
    H1| H2 | H3 | -------------------
    | | | H4 | H5 | H6
    --------------------------------------

    In the plain HTML, this can be achieved using RowSpan and ColumnSpan
    attributes. But how to apply it to the DataGrid?
    I have some experience in manipulating a DataGrid content from a code.
    So I decided to add one extra header row below the existing one and thru
    modifying theirs cells, get what I need. But my test code failed at a very
    first step!
    I called below code from DataGrid_Prerender and instead of getting an extra
    header row with a text "test", I got an empty row. Without <td> elements
    inside!

    //this fragment from browser's Source View
    <tr
    style="color:White;background-color:#006699;font-size:8pt;font-weight:bold;">
    </tr>

    //the code from Grid_Prerender()

    DataGridItem hdr = null, sub;
    TableCell cell;
    int c;

    for (c = 0; c < Grid.Controls[0].Controls.Count; c++)
    {
    hdr = Grid.Controls[0].Controls[c] as DataGridItem;
    if (hdr != null && hdr.ItemType == ListItemType.Header)
    break;
    }
    if (hdr == null || hdr.ItemType != ListItemType.Header)
    return;
    sub = new DataGridItem(-1, -1, ListItemType.Header);
    cell = new TableCell();
    cell.ColumnSpan = hdr.Cells.Count;
    cell.Text = "test";
    sub.Cells.Add(cell);
    Grid.Controls[0].Controls.AddAt(c + 1, sub);

    If above problem will be solved, my next step is to try to
    create/move/rowspan/colspan
    cells from above 2 header rows and, may be, I will get some result.
     
    Tumurbaatar S., Nov 20, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rosh shah

    adding subHeader to dataGrid

    rosh shah, Oct 5, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    156
    Ian Oldbury
    Oct 5, 2004
Loading...

Share This Page