Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Double header in datagrid

Double header in datagrid

Scheduled Pinned Locked Moved ASP.NET
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    luckyv
    wrote on last edited by
    #1

    Is it Possible to have 2 header rows(header for header)for a scrolling datagrid with fixed header.Plz Help. Thanks in advance. -- modified at 3:10 Thursday 20th April, 2006

    M 1 Reply Last reply
    0
    • L luckyv

      Is it Possible to have 2 header rows(header for header)for a scrolling datagrid with fixed header.Plz Help. Thanks in advance. -- modified at 3:10 Thursday 20th April, 2006

      M Offline
      M Offline
      Miguel_TX
      wrote on last edited by
      #2

      Check out this solution: http://forums.asp.net/390809/ShowPost.aspx[^] Here is the C# Equivalent (with some added stuff I did to help those with possible questions): private void DataGrid1_PreRender(object sender, System.EventArgs e) { //This MUST be done in the Pre-Render function. Otherwise will have errors if running this code outside of the PreRender function. DataGridItem dgItem = new DataGridItem(0,0,ListItemType.Header); TableCell myCell = new TableCell(); myCell.ColumnSpan = 2; //This Merges Cells together. myCell.Text = "Test"; myCell.BackColor = Color.Lavender; //Change the back color of a single cell. myCell.VerticalAlign = VerticalAlign.Middle;//This Centers the text vertically for a single cell. dgItem.Cells.Add(myCell); dgItem.HorizontalAlign = HorizontalAlign.Center;//This centers the text for the entire dgItem (which in this case is the additional header we just added). DataGrid1.Columns[1].HeaderStyle.BackColor = Color.LemonChiffon;//This changes the color for an entire column, not needed, but is neat to see if you were thinking about doing something like this in the future - now you know how to. DataGrid1.Controls[0].Controls.AddAt(0, dgItem); //Change the integer in the AddAt() function to insert the header somewhere else in the datagrid (like 1 for below the original header, or 5 if for some inexplicable reason you want two totally separated headers with rows of data in between them. } Hope you guys liked it! Big Thanks to Jim Ross and his post at forums.ASP.Net website and his source who gave him the original VB code: Anand Hegde (MSFT). - M

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups