Monday, April 19, 2010

Asp .NET Multiheader Gridview

Para agregar mas de un header en un Gridview, agregar el sig codigo al evento RowCreate del mismo:

Protected Sub gvRetornosSGrupo_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvRetornosSGrupo.RowCreated

If (e.Row.RowType = DataControlRowType.Header) Then
Dim gvr As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header,
DataControlRowState.Normal)

Dim thc As TableHeaderCell = New TableHeaderCell()

thc = New TableHeaderCell()
thc.ColumnSpan = 4
thc.Text = "Retornos Sin Grupo"
gvr.Cells.Add(thc)

gvRetornosSGrupo.Controls(0).Controls.AddAt(0, gvr)
End If


End Sub