Touchy Vivace
Touchy Vivace

Reputation: 304

Sort File Creationtime in gridview

i have a gridview that retrieve a list of name and file creationdatetime from servermappath and try to sort by creationtime by this

    Function GetTable() As DataTable

        Dim filePaths() As String = getFiles(Server.MapPath("~/path/"), "*" + Session("Uauthen") + "*", SearchOption.AllDirectories)
        Dim tb As New DataTable()
        tb.Columns.Add("FileName")
        tb.Columns.Add("FileCreationTime")
        Dim dv As New DataView(tb)
  dv.Sort = "FileCreationTime DESC"
        Dim sortedDT As DataTable = dv.ToTable()

        'Dim files As List(Of ListItem) = New List(Of ListItem)
        For Each filePath As String In filePaths

            sortedDT.Rows.Add(Path.GetFileName(filePath), File.GetCreationTime(filePath).ToString("d MMM yyyy hh:mm:ss"))


        Next

        Return sortedDT

    End Function

but nothing happened on gridview that still not sort there is another way to sort them ?

Upvotes: 0

Views: 61

Answers (1)

Yu Yenkan
Yu Yenkan

Reputation: 765

define variable type in column

tb.Columns.Add("FileName", typeof(String))
tb.Columns.Add("FileCreationTime",typeof(DateTime))

DataTable DateTime Column Sort:

http://forums.asp.net/p/1267353/2393006.aspx

Upvotes: 2

Related Questions