adding sub group headers dynamically for datagrid in prerender

Discussion in 'ASP .Net Datagrid Control' started by Anand, Nov 16, 2004.

  1. Anand

    Anand Guest

    problem.. the code creates a header row when i see the rendered hTML
    but it is not creating the table cell inside the row. ie. it is
    rendering as <tr></tr>
    instead of <tr></td> mmmmm </td></tr>

    the namevalues is an array which contains all the categories of my
    products at respective index position with respect to the grid. The
    array is filled while itemdatabound.

    below is the code i wrote in pre render..




    private void itemsDataGrid_PreRender(object sender, System.EventArgs
    e)
    {

    //Just before the Datagrid renders its output, add the extra
    separator rows
    DataGrid dg = (DataGrid)sender;

    Table tbl = (Table) dg.Controls[0];
    DataGridItem dgi;
    TableCell cell;

    int i;
    int iAdded = 0;

    for (i=0; i < nameValues.GetUpperBound(0); i++)
    {
    if (nameValues != DataTypeHelper.NullString && nameValues
    != null)
    {
    //Just so it picks up the formatting class for my Header, could
    have used ListItemType.Item
    // dgi = new DataGridItem(0, 0, ListItemType.Header);
    dgi = new DataGridItem(5, 5, ListItemType.Header);
    cell = new TableCell();
    cell.ColumnSpan =7;
    cell.Text = nameValues;
    dgi.Cells.Add(cell);

    //Add one to skip past the Header item
    // //tbl.Controls.AddAt(i + iAdded + 1, dgi);

    itemsDataGrid.Controls[0].Controls.AddAt(i + iAdded + 2, dgi);
    iAdded = iAdded + 1;

    added = false;
    }
    }
    }
    }


    any help is greatly appreciated

    thanks
    anand
    Anand, Nov 16, 2004
    #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. loga123
    Replies:
    2
    Views:
    314
    loga123
    May 20, 2006
  2. Ben
    Replies:
    2
    Views:
    859
  3. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,961
    Lawrence D'Oliveiro
    May 20, 2011
  4. Replies:
    1
    Views:
    151
    marss
    Sep 6, 2007
  5. Replies:
    0
    Views:
    102
Loading...

Share This Page