Hi William,
You just need to add some more dummy cells before the span. You could use
the same technique for adding dummy cells after the span.
Ken
Private Sub DataGrid1_PreRender _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles DataGrid1.PreRender
' Spans columns in an ASP.NET datagrid header
' Ken Cox Microsoft MVP [ASP.NET]
Dim intCounter As Integer
Dim dgitem As New DataGridItem _
(0, 0, ListItemType.Header)
Dim tblCell As TableCell
' Pad cells before the spanning cell
' Adjust the count as necessary
For intCounter = 0 To 6
tblCell = New TableCell
tblCell.ColumnSpan = 1
tblCell.Text = " "
dgitem.Cells.Add(tblCell)
Next
tblCell = New TableCell
tblCell.ColumnSpan = 2
tblCell.Text = "Hours"
dgitem.Cells.Add(tblCell)
DataGrid1.Controls(0).Controls.AddAt _
(0, dgitem)
End Sub
William Gower said:
Thanks it almost works. I want it to appear over the 8 and 9th columns in
the header. Which value do I change for it to do that?