Hi RD,
Not sure about efficiency, but here's a way to do it in the codebehind. Just
create an imagebutton, add it to a cell, add that to a new header, wipe the
old header and bake for .01 seconds....
Private Sub DataGrid1_ItemDataBound _
(ByVal sender As Object, _
ByVal e As _
System.Web.UI.WebControls.DataGridItemEventArgs) _
Handles DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Header Then
' Get the collection of cells from the grid
Dim tcells As TableCellCollection
' Create an imagebutton
Dim imgBtn As New ImageButton
' Assign the URL
imgBtn.ImageUrl = "
http://www.gc.ca/images/flag.gif"
' Get the collection of existing cells so we can get a count
tcells = e.Item.Cells
' Create a new cell
Dim fcell As New TableCell
' Add the image button to the new table cell
fcell.Controls.Add(imgBtn)
' Span the cell to however many columns there are
fcell.ColumnSpan = tcells.Count
' Create a new header object
Dim dgItemHeader As New DataGridItem _
(0, 0, ListItemType.Header)
Dim dgItemOldHeader As DataGridItem
'Create an instance of the header
'from the current header object
dgItemOldHeader = e.Item
' Delete the existing header
DataGrid1.Controls(0).Controls.Remove(dgItemOldHeader)
' Add the cell to the header
dgItemHeader.Cells.Add(fcell)
dgItemHeader.Visible = True
' Add the header to the datagrid
DataGrid1.Controls(0).Controls.Add(dgItemHeader)
End If
End Sub