Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 961375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:20:02+00:00 2026-05-16T01:20:02+00:00

I have a page which lists all the files in a particular folder (all

  • 0

I have a page which lists all the files in a particular folder (all PDFs), using a data-table and gridview.

I’m currently sorting this table by the filename (by using a dataview), which isn’t that helpful, and I want the gridview of files sorted by the file created or file modified date (as recorded in Windows).

If that’s not possible, a second option would be to extract the date from the file name string (no problem doing that), and sort the dataview/datatable or gridview based on that.
Example Filename: DailySalesReport-1-15-2010. My only hangup with this is how do I sort on date, when it’s a string value? Convert to date? How would I sort the whole dataset based on this converted value?

Thanks for any ideas!

Protected Sub PageLoad(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Not IsPostBack Then
        Dim dt As New DataTable()
        dt.Columns.Add("Daily Reports", Type.[GetType]("System.String"))

        For Each name As [String] In System.IO.Directory.GetFiles(Server.MapPath("~\reports\pdf\")) '"
                dt.Rows.Add(New Object() {name})
        Next

        Dim dv As DataView = dt.DefaultView
        dv.Sort = dt.Columns(0).ToString + " " + "desc"
        dt = dv.ToTable

        Me.gvDaily.DataSource = dt
        Me.gvDaily.DataBind()

    End If
End Sub



Protected Sub gvDaily_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)

    If e.Row.RowType = DataControlRowType.DataRow Then
        Dim hl As New HyperLink()
        hl.NavigateUrl = "~\reports\pdfs\" + e.Row.Cells(0).Text '"
        hl.Text = "Daily Report"
        e.Row.Cells(0).Text = ""
        e.Row.Cells(0).Controls.Add(hl)
    End If

End Sub


<asp:GridView ID="gvDaily" runat="server" Height="80px" Width = "180px" CssClass="tableText"    
          OnRowDataBound="gvDaily_RowDataBound">
          <RowStyle HorizontalAlign="center" />                
</asp:GridView>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:20:03+00:00Added an answer on May 16, 2026 at 1:20 am

    Try this new page load. With a “FileDate” column.

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim dt As New Data.DataTable()
            dt.Columns.Add("Daily Reports", Type.[GetType]("System.String"))
            dt.Columns.Add("FileDate", GetType(System.DateTime))
    
            For Each name As [String] In System.IO.Directory.GetFiles(Server.MapPath("~\reports\pdf\"))
    
                Dim fi As New System.IO.FileInfo(name)
    
                dt.Rows.Add(New Object() {name, fi.LastWriteTime})
            Next
    
            Dim dv As DataView = dt.DefaultView
            dv.Sort = dt.Columns("FileDate").ColumnName & " " & "desc"
            dt = dv.ToTable
    
            Me.gvDaily.DataSource = dt
            Me.gvDaily.DataBind()
    
        End If
    End Sub
    

    To show just the column you want, use this as your Gridview.

    <asp:GridView ID="gvDaily" runat="server" Height="80px" Width = "180px" CssClass="tableText"    
              OnRowDataBound="gvDaily_RowDataBound" AutoGenerateColumns="false">
              <RowStyle HorizontalAlign="center" />
        <Columns>
            <asp:BoundField DataField="Daily Reports" HeaderText="Daily Report" />
        </Columns>               
    </asp:GridView>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that was in a folder named project, I moved all
I have been using Ruby 1.8 + Rails 2.3.5 with oracle_enhanced and it works
I am in the process of designing a web application which will have multiple
I'm running through theForger's Win32 API Programming Tutorial . On page 4 he suggests
I have an ASP.NET website and from one of the web pages I need
I'm working on an HTML5 mobile app and I initially have the background of
Hi I was wondering if this is possible, this is my scenario, I have
Wondering if someone could help with with some Spring.net IOC integration into a .aspx
I need to optimize the loading speed of several existing websites. One of the
I use the following functions to set error control: set_error_handler set_exception_handler When an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.