CassidyHunt
IS-IT--Management
Does anyone have a method of inserting a row into a gridview perhaps on the prerender or render events of the gridview control?
Thanks
Cassidy
Thanks
Cassidy
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
If _SortedFlag Then
Dim table As Table = DirectCast(grid1.Controls(0), Table)
Dim htLookUp As New Hashtable
For Each row As GridViewRow In grid1.Rows
Dim realIndex As Integer = table.Rows.GetRowIndex(row)
Dim text As String = row.Cells(_SortColumnIndex).Text
If Not htLookUp.ContainsKey(text) Then
htLookUp.Add(text, Nothing)
Dim newHeaderRow As New GridViewRow(realIndex, realIndex, DataControlRowType.DataRow, DataControlRowState.Normal)
Dim newCell As New TableCell()
newHeaderRow.Cells.Add(newCell)
newCell.ColumnSpan = grid1.Columns.Count
newCell.BackColor = Drawing.Color.Gray
newCell.ForeColor = Drawing.Color.White
newCell.Font.Bold = True
newCell.Text = _SortColumnHeader & " : " & text
table.Controls.AddAt(realIndex, newHeaderRow)
End If
Next
End If
MyBase.Render(writer)
End Sub
Go for it...I'm sure it will help someone.I don't know if anyone would be interested by I will post my complete extended gridview class here.