Solved it:
Private Sub GroupHeader(ByV al Item As
System.Web.UI.W ebControls.Data GridItem)
Static LastItem As System.Web.UI.W ebControls.Data GridItem 'track the
last item
Static Groups As Integer 'track number of group rows added to
datagrid
If (Not LastItem Is Nothing) Then
'compare text value in prior row to text in current row (change cell as
appropriate)
'if text value hasn't changed, still in same group, exit
If LastItem.Cells( 3).Text = Item.Cells(3).T ext Then Exit Sub
End If
'increment group counter
Groups += 1
'create a new cell with appropriate properties
Dim tc As TableCell = New TableCell
tc.ColumnSpan = "4" 'span the table
tc.Text = Item.Cells(3).T ext
tc.ForeColor = System.Drawing. Color.White
tc.BackColor = System.Drawing. Color.Firebrick
'create a new row. probably doesn't matter with listittemtype
Dim dgi As DataGridItem
If Item.ItemType = ListItemType.It em Then
dgi = New DataGridItem(0, 0, ListItemType.It em)
ElseIf Item.ItemType = ListItemType.Al ternatingItem Then
dgi = New DataGridItem(0, 0, ListItemType.Al ternatingItem)
End If
'add cell to new row
dgi.Cells.Add(t c)
'add row to datagrid; use group counter to correctly position row (each row
that is added
increments the ItemIndex)
DataGrid1.Contr ols(0).Controls .AddAt(Item.Ite mIndex + Groups, dgi)
'store this item to be use in next pass
LastItem = Item
End Sub
"Craig Buchanan" <so*****@somewh ere.com> wrote in message
news:O4******** ******@TK2MSFTN GP12.phx.gbl...
Is there a way to add a row to a datagrid during the ItemDataBound event?
I would like to add a 'header' row before the start of a group of rows.
Thanks,
Craig Buchanan