DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: How to read file names from a folder and display them in a datagrid as links?

  1. #1
    Join Date
    Nov 2007
    Posts
    69

    How to read file names from a folder and display them in a datagrid as links?

    Hi
    I am trying to read in the file names from a folder directory. After that i want to display the names in a datagrid as links. So if some one clicks on one of the names it will open the file. the files are .doc or .pdf files. Can anyone direct me on doing this. in VB.NET

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    To get the file names do something like
    Code:
    System.IO.Directory.GetFiles( "path", "pattern")
    I don't know about loading them into a DataGrid as I've never, ever used one. For this type of thing, I typically use a ListView.

    However, if you are familiar with the DataGrid, then loading the return shouldn't be too difficult.

  3. #3
    Join Date
    Nov 2007
    Posts
    69
    Yes I have got the file name but i put it into a array. and bind it to the datagrid. But i could not figure out how to make the file name links as well.

  4. #4
    Join Date
    Jul 2007
    Posts
    161
    For a grid view (not sure if this is what you call a data grid):

    <asp:TemplateField >
    <HeaderTemplate >File</HeaderTemplate>
    <ItemTemplate >
    <a href=<%# Eval(***FileLocation***) %>"> <%#Eval(***FileLocation***)%></a>
    </ItemTemplate>
    </asp:TemplateField>

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Instead of a TemplateField, you may find it easier to use a HyperLinkColumn. For more information, see http://samples.gotdotnet.com/quickst..._datagrid.aspx .
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  6. #6
    Join Date
    Nov 2007
    Posts
    69
    I'm sorry,
    Yes I am talking about a gridview. Let us say that I have the file names already binded to the gridview. Now the column contains file names. How to make them links to their source files. And if someone added files to the folder the colde will automatically pick them up. Any ideas

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  8. #8
    Join Date
    Nov 2007
    Posts
    69
    That i understand, I got it where it reads the file name and modified date. What I have in the database table is three columns
    File name----------------Title-----------------modified date
    i want the admin to be able to add in files directely. Like a button where it broweses to add and save a file. The file name and modified date will be added to gridview, but how to insert a title for the file name.

Similar Threads

  1. Display All Files In A Folder
    By RichardGR in forum .NET
    Replies: 2
    Last Post: 12-19-2007, 02:26 PM
  2. Compare last 10 digits of a file
    By mkebe in forum VB Classic
    Replies: 9
    Last Post: 03-21-2006, 11:58 AM
  3. Replies: 1
    Last Post: 09-11-2002, 04:37 PM
  4. Replies: 0
    Last Post: 06-28-2000, 10:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center