【程式開發小筆記】GridView 合併欄位小技巧
Private Sub GridView1_PreRender(sender As Object, e As System.EventArgs) Handles GridView1.PreRender
Dim i, j As Integer
For i = GridView1.Rows.Count - 1 To 1 Step -1
Dim currentRow As GridViewRow = GridView1.Rows(i)
Dim previousRow As GridViewRow = GridView1.Rows(i - 1)
Dim My_currentRow As Label = CType(currentRow.Cells(0).FindControl("Label1"), Label)
Dim My_previousRow As Label = CType(previousRow.Cells(0).FindControl("Label1"), Label)
For j = 0 To currentRow.Cells.Count - 1
If My_currentRow.Text = My_previousRow.Text Then
If previousRow.Cells(0).RowSpan = 0 Then
If currentRow.Cells(0).RowSpan = 0 Then
previousRow.Cells(0).RowSpan += 2
Else
previousRow.Cells(0).RowSpan = currentRow.Cells(0).RowSpan + 1
End If
End If
currentRow.Cells(0).Visible = False
End If
Next
Next
End Sub
本文來自: https://blog.xuite.net/anadachien/MyQuilt/520064624-%E3%80%90%E7%A8%8B%E5%BC%8F%E9%96%8B%E7%99%BC%E5
留言列表