0 Replies - 1039 Views - Last Post: 07 September 2014 - 01:05 PM Rate Topic: -----

#1 RarJacobsen   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-September 14

Include two headerrows in gridview and assign <thead> around t

Posted 07 September 2014 - 01:05 PM

Hi

I'm having some trouble including two headerrows to a gridview and including these two headerrows inside <thead>

It's easy enough to include one headerrow inside <thead>- and it is also easy enough to create two headerrows without <thead>

At this moment I'm creating the two headerrows with the following code :

    Protected Sub grdData_RowCreated(sender As Object, e As GridViewRowEventArgs) Handles grdData.RowCreated
        If e.Row.RowType = DataControlRowType.Header Then
            'Creating a gridview object           
            Dim objGridView As GridView = DirectCast(sender, GridView)

            'Creating a gridview row object
            Dim objgridviewrow As New GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert)

            'Creating a table cell object
            Dim objtablecell As New TableHeaderCell()

            'Count numbers of columns to generate correct amount of weeks
            Dim strColumnCount As Integer = objGridView.Columns.Count - 1
            Dim strWeeksToCreate = Math.Floor(strColumnCount / 7)

            AddMergedCells(objgridviewrow, objtablecell, 0, "Medarbejder", System.Drawing.Color.LightSteelBlue.Name)

            For x = 0 To strWeeksToCreate
                AddMergedCells(objgridviewrow, objtablecell, 7, "Uge nr" & x, System.Drawing.Color.LightGreen.Name)
            Next

            If strColumnCount > 1 + (strWeeksToCreate * 7) Then
                AddMergedCells(objgridviewrow, objtablecell, strColumnCount - (1 + (strWeeksToCreate * 7)), "Uge nr" & strWeeksToCreate + 1, System.Drawing.Color.LightSkyBlue.Name)
            End If

            objGridView.Controls(0).Controls.AddAt(0, objgridviewrow)
        End If

    End Sub




And the easy way to include <thead> is with this small code:

grdData.UseAccessibleHeader = True
grdData.HeaderRow.TableSection = TableRowSection.TableHeader



But I cant get it to work when combining these codes - how can it be done?

Thanks in advance

Is This A Good Question/Topic? 0
  • +

Page 1 of 1