方式有很多種,我是在GridView的RowDataBound事件處理,處理方式如下範例:
Private Sub 欄位處理(ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
e.Row.Cells.Clear()
Dim headROW As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
Dim head2Cell As TableCell
head2Cell = New TableCell()
With head2Cell
.Text = "分配方式"
.HorizontalAlign = HorizontalAlign.Center
.ColumnSpan = 2
End With
headROW.Cells.Add(head2Cell)
head2Cell = New TableCell
With head2Cell
.Text = "職務名稱"
.HorizontalAlign = HorizontalAlign.Center
End With
headROW.Cells.Add(head2Cell)
gv.Controls(0).Controls.Add(headROW)
End Sub
Protected Sub gv_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
'總共有三個欄位,將第一個和第二個Spain起來
欄位處理(e)
End If
End Sub
沒有留言:
張貼留言