Click here to Skip to main content
15,885,141 members
Articles / Web Development / ASP.NET
Alternative
Article

Merge DataGrid Header

Rate me:
Please Sign up or sign in to vote.
4.67/5 (3 votes)
4 May 2012CPOL 20.4K   5  
This is an alternative for "Merge DataGrid Header"

Introduction

Another way to is to handle the ItemDataBound event. 

Background

You want to do colspan on a DataGrid header.

Using the code

Catch ItemDataBound. Test for the header. You can also do colspan tricks to data rows.

VB
Private Sub AreaGrid_ItemDataBound(ByVal sender As Object, _
        ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
        Handles AreaGrid.ItemDataBound
    If e.Item.ItemType = ListItemType.Header Then
     
        'remove third cell and extend the second cell 
            e.Item.Cells.RemoveAt(2)
            e.Item.Cells(1).ColumnSpan = 2
          
        Return 
    End If
End Sub

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Unknown
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --