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.
Imports System
Imports System.ComponentModel
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace cmi.bin.customControls
<ToolboxData("<{0}:cmiReversableGrid runat=server></{0}:cmiReversableGrid>")> Public Class cmiReversableGrid
Inherits System.Web.UI.WebControls.DataGrid
Private mvarrepeatHeader As Boolean = 0
Private mvarrepeatInterval As Integer = 5
Private mvarheaderText As New String(String.Empty)
Private rowCounter As Integer = 0
Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)
MyBase.Render(output)
End Sub
Private Sub insertHeader(ByVal o As Object, ByVal e As DataGridItemEventArgs) Handles MyBase.ItemCreated
If mvarrepeatHeader Then
If e.Item.ItemType = Web.UI.WebControls.ListItemType.Header Then
rowCounter = 0
ElseIf e.Item.ItemType <> Web.UI.WebControls.ListItemType.Footer _
And e.Item.ItemType <> Web.UI.WebControls.ListItemType.Pager _
And e.Item.ItemType <> Web.UI.WebControls.ListItemType.Separator Then
rowCounter += 1
If rowCounter Mod mvarrepeatInterval = 0 Then
addRow(o, e)
End If
End If
End If
End Sub
Private Sub addRow(ByVal o As Object, ByVal e As DataGridItemEventArgs)
Dim dg As DataGrid = o
Dim tc As New TableCell()
tc.Controls.Add(New LiteralControl(mvarheaderText))
Dim di As New DataGridItem(e.Item.ItemIndex + 1, 0, ListItemType.Item)
di.Cells.Add(tc)
Dim t As Table = dg.Controls(0)
t.Rows.Add(di)
End Sub
Public ReadOnly Property sortExpression() As String
Get
Dim output As String
output = sortField
If Not sortAscending Then
output &= " DESC"
End If
Return output
End Get
End Property
Public Property sortField() As String
Get
Dim o As Object = ViewState.Item("sortField")
Dim output As String
If o Is Nothing Then
output = String.Empty
Else
output = o.ToString()
End If
Return output
End Get
Set(ByVal Value As String)
If Value = sortField Then
sortAscending = Not sortAscending
End If
ViewState.Item("sortField") = Value
End Set
End Property
Public WriteOnly Property repeatHeader() As Boolean
Set(ByVal Value As Boolean)
mvarrepeatHeader = Value
End Set
End Property
Public WriteOnly Property repeatInterval() As Integer
Set(ByVal Value As Integer)
mvarrepeatInterval = Value
End Set
End Property
Public WriteOnly Property headerText() As String
Set(ByVal Value As String)
mvarheaderText = Value
End Set
End Property
Private Property sortAscending() As Boolean
Get
Dim o As Object = ViewState.Item("sortAscending")
Dim output As String
If o Is Nothing Then
output = True
Else
output = CBool(o)
End If
Return output
End Get
Set(ByVal Value As Boolean)
ViewState.Item("sortAscending") = Value
End Set
End Property
End Class
End Namespace