Skip to content

Use with merge cells #64

@robertomoo

Description

@robertomoo

When I try to merge some cells with the class down here I have a problem with the visualisation of the cells and don't know why the text is not in the center if already put the property in the web.css,

Public Class Class1
    Public Shared Sub MergeRows(ByVal gridView As GridView)
        If gridView.Rows.Count > 2 Then
            Dim rowIndex As Integer = gridView.Rows.Count - 2
            While rowIndex >= 0
                Dim row As GridViewRow = gridView.Rows(rowIndex)
                Dim previousRow As GridViewRow = gridView.Rows(rowIndex + 1)
                Dim text As String = ""
                For cellIndex As Integer = 0 To row.Cells.Count - 1
                    'if to identify which column is going to merge its cells, (cellindex is for columns)
                    If cellIndex = 0 Or cellIndex = 1 Then
                        Try
                            text = (CType(row.Cells(cellIndex).FindControl("lbl" & cellIndex), Label)).Text
                        Catch ex As Exception
                            text = ""
                            Try
                                text = (CType(row.Cells(cellIndex).FindControl("lbl" & cellIndex), Image)).ImageUrl
                            Catch ex3 As Exception
                                text = ""
                            End Try
                        End Try
                        Dim previousText As String = ""
                        Try
                            previousText = (CType(previousRow.Cells(cellIndex).FindControl("lbl" & cellIndex), Label)).Text
                        Catch ex As Exception
                            Try
                                previousText = (CType(previousRow.Cells(cellIndex).FindControl("lbl" & cellIndex), Image)).ImageUrl
                            Catch ex2 As Exception
                                previousText = ""
                            End Try
                        End Try
                        If text = previousText Then
                            row.Cells(cellIndex).RowSpan = If(previousRow.Cells(cellIndex).RowSpan < 2,
                                2, previousRow.Cells(cellIndex).RowSpan + 1)
                            previousRow.Cells(cellIndex).Visible = False
                        End If
                    End If
                Next
                rowIndex -= 1
            End While
        End If
    End Sub
End Class

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions