0

I have a gridview on an aspx page that I fill from sql server (gridview source is a datatable). One of the fields on my grid is a file name. I want my user to be able to click a link and download the file.

Here is my link:

<asp:TemplateField HeaderText="Download File" 
  <ItemTemplate >
    <asp:HyperLink runat="server"  
        NavigateUrl='<%# Eval("FileName")%>' 
        text="Get File">
    </asp:HyperLink>
   </ItemTemplate>
 </asp:TemplateField>

The filename is provided from code behind, via 'Eval'.

This downloads the file just fine if the file is in the same directory as my application, but I have over 700 files, so I keep them in a sub-folder.

Is there some way to point the bound field to a sub-directory? Any help is appreciated.

buckshot
  • 315
  • 4
  • 15

1 Answers1

0

In codebehind include relative path in filename (use / and not ), instead on only filename.

subfloder/filename

or if the subfolder is always the same

NavigateUrl =  '<%# "~/YourSubFolder/" + Eval("filename") %>'>
José Matos
  • 569
  • 4
  • 13