Dim node As XmlNode = versionxml.CreateElement(XmlNodeType.Element, "Result", Nothing)
'Create child node in parent node
Dim nodeID As XmlNode = versionxml.CreateElement("ID")
nodeID.InnerText = ID
Dim nodeVersion As XmlNode = versionxml.CreateElement("VERSION_NO")
nodeVersion.InnerText = VERSION_NO
Dim nodeTitle As XmlNode = versionxml.CreateElement("TITLE")
nodeTitle.InnerText = TITLE
Dim nodeTime As XmlNode = versionxml.CreateElement("TIME")
nodeTime.InnerText = TIME
'Add to parent Node
node.AppendChild(nodeID)
node.AppendChild(nodeVersion)
node.AppendChild(nodeTitle)
node.AppendChild(nodeTime)
'Add to elements collection
versionxml.DocumentElement.AppendChild(node)
'Save xml
versionxml.Save(Application.StartupPath & "\version.xml")
Public Class my_GridView_Generic
Inherits GridView
...
...
Protected Overrides Sub OnSorting(e As System.Web.UI.WebControls.GridViewSortEventArgs)
If Not e.SortExpression.Equals(String.Empty) Then
ViewState("SortDirection") = If(ViewState("SortDirection") = Nothing OrElse
ViewState("SortDirection").Equals("") OrElse
ViewState("SortDirection") = "0", "1", "0")
Me._DataModel = SortColumnByLamda(e.SortExpression, ViewState("SortDirection"))
Me.DataSource = Me._DataModel 'DirectCast(Me._DataModel, List(Of Any type))
Me.DataBind()
Me.HeaderRow.Cells(Me.GetColumnIndex(e.SortExpression)).CssClass = If(ViewState("SortDirection") = "0",
"sortasc-header", "sortdesc-header")
'MyBase.OnSorting(e)
End If
End Sub
Private Function SortColumnByLamda(ByVal colName As String, ByVal sortDirection As String) As Object
Dim lstDyn = Enumerable.Cast(Of Object)(Me._DataModel)
If sortDirection = "1" Then 'Descending
lstDyn = lstDyn.OrderByDescending(Function(c) c.GetType().InvokeMember(colName, BindingFlags.GetProperty, Nothing, c, Nothing)).ToList()
Else
lstDyn = lstDyn.OrderBy(Function(c) c.GetType().InvokeMember(colName, BindingFlags.GetProperty, Nothing, c, Nothing)).ToList()
End If
Return lstDyn
End Function
End Class