GridView 中的 RowSpan





0/5 (0投票)
如果在表格中需要合并列或行,可以在 HTML 设计中使用 RowSpan 和 ColSpan。RowSpan 可以轻松地在 ASP.NET 中实现。
如果在表格中需要合并列或行,可以在 HTML 设计中使用 RowSpan 和 ColSpan。
RowSpan 可以轻松地在 ASP.NET GridView 或 DataGrid Web 控件中实现。 在这篇 Wiki 文章中,您将找到一个示例,说明如何在 GridView 的 RowCreated 事件中使用 RowSpan。
以下是示例代码
' Control the row type, continue if it is a DataRow 
If e.Row.RowType = DataControlRowType.DataRow Then
    ' If it is the first row add a new cell
    If e.Row.RowIndex = 0 Then
        Dim tc As New TableCell()
        tc.RowSpan = 1
        e.Row.Cells.Add(tc)
    Else
        ' In the following rows alter the RowSpan property of the recently added cell by one
        Dim tc As TableCell = GridView1.Rows(0).Cells(GridView1.Rows(0).Cells.Count - 1)
        tc.RowSpan = tc.RowSpan + 1
    End If
End If

