在某些情況下,可能需要將流水號累加,這時可以將覆寫的InitializeCell(ByVal cell As System.Web.UI.WebControls.DataControlFieldCell, ByVal cellType As System.Web.UI.WebControls.DataControlCellType, ByVal rowState As System.Web.UI.WebControls.DataControlRowState, ByVal rowIndex As Integer)修改為如下程式碼
Public Overrides Sub InitializeCell(ByVal cell As System.Web.UI.WebControls.DataControlFieldCell, ByVal cellType As System.Web.UI.WebControls.DataControlCellType, ByVal rowState As System.Web.UI.WebControls.DataControlRowState, ByVal rowIndex As Integer) MyBase.InitializeCell(cell, cellType, rowState, rowIndex) If cellType = DataControlCellType.DataCell Then cell.Text = (OwnerGridView.PageIndex * OwnerGridView.PageSize + rowIndex + 1).ToString()若需同時支援累加和不累加流水號,可自行加入屬性做判斷。End IfEnd Sub Private ReadOnly Property OwnerGridView() As GridView Get Return DirectCast(Me.Control, GridView) End Get End Property