Show muliple headers in datagrid

F

Flare

Hi

Im trying to make a datagrid wich have a header and a subheader directly
under. The top header is the problem sine it should "group" the subheader. I
imagine to use columspan on the top header. I just cant see how i should
define this topheader.

I wanrt something like this: where [] is a cell

[General info ] [ Births ]
[ID] [Customer] [Name] [2000] [2001] [2002] [2003]

Reagards
Anders Jacobsen, Denmark
 
S

Sushila [MVP]

Hi

In the DataGrid PreRender Event try below code
Dim dgItem As New DataGridItem(0, 0, ListItemType.Header)
Dim tbCell As New TableCell
tbCell.ColumnSpan = 3 'Set it to the colspan that you want
tbCell.Text = "General Information"
tbCell.Attributes.Add("style", "text-align:center")
dgItem.Cells.Add(tbCell)
DataGrid1.Controls(0).Controls.AddAt(0, dgItem)

HTH

Regards
Sushila
 
F

Flare

Ah to quick. It dosent work. The header is applied to the bottom of the datagrid. Ive tried to use the OnItemCreate. This works great, but strange enough not when the datagrid is placed in a UserControl and then dynamicly loaded with LoadControl. very strange very strange. If i drag and drop the Usercontrol with the grid it works fine

Anders
"Sushila [MVP]" <[email protected]> skrev i en meddelelse Hi

In the DataGrid PreRender Event try below code
Dim dgItem As New DataGridItem(0, 0, ListItemType.Header)
Dim tbCell As New TableCell
tbCell.ColumnSpan = 3 'Set it to the colspan that you want
tbCell.Text = "General Information"
tbCell.Attributes.Add("style", "text-align:center")
dgItem.Cells.Add(tbCell)
DataGrid1.Controls(0).Controls.AddAt(0, dgItem)

HTH

Regards
Sushila
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top