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

  • SEARCH
  • Home
  • 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 7894719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:28:01+00:00 2026-06-03T07:28:01+00:00

I have a problem with file download. I have a grid which shows the

  • 0

I have a problem with file download. I have a grid which shows the file name and a link to download that file.
This is the code of my grid.

<asp:GridView ID="gv7" runat="server" AllowPaging="True" CssClass="tbl_green_parrot"
PageSize="5" Width="100%" AutoGenerateColumns="False" EmptyDataText="No Scheme data available" DataKeyNames="FilePath" OnPageIndexChanging="gv7_PageIndexChanging"             onrowdatabound="gv7_RowDataBound">
  <AlternatingRowStyle CssClass="tbl_green_parrot1" />
 <FooterStyle CssClass="tbl_green_parrotfoot" />
 <PagerStyle CssClass="tbl_green_parrotpager" />
 <SelectedRowStyle CssClass="tbl_green_parrotselect" />
 <EmptyDataRowStyle CssClass="tbl_green_parrotempty" />
 <Columns>
   <asp:TemplateField HeaderText="File Name">
   <ItemTemplate>
   <asp:HyperLink ID="lnkFile" Target="_blank" CausesValidation="false" runat="server"
   Text='<%# Bind("DisplayName") %>' NavigateUrl='<%# Bind("FilePath") %>' />
   </ItemTemplate>
   </asp:TemplateField>
   <asp:TemplateField HeaderText="Download" ItemStyle-Width="25px" ItemStyle-HorizontalAlign="Center">
   <ItemTemplate>
   <a id="lnkDLoad" href='<%# Bind("FilePath") %>' runat="server" target="_blank">
   <img src="Images/download.png" alt="Download" />
   </a>
   </ItemTemplate>
   <ItemStyle HorizontalAlign="Center" Width="25px" ></ItemStyle>
   </asp:TemplateField>
 </Columns>

Here I bind the filepath to the <a> tag. This code is running when I have the file in the same root folder in the website. But when I attempt to download the file which is inside the folder it doesn’t download.

The code behind for downloading:

DataTable new_dt = new DataTable();
    new_dt.Columns.Add("DisplayName");
    new_dt.Columns.Add("FileName");
    new_dt.Columns.Add("FilePath");
    string Query = "SELECT DisplayName,FilePath,Universal From DistScheme";
    dt = DataAccessLayer.DAL.getFromDataTable(Query);
    string filename = "";
    if (dt.Rows.Count > 0)
    {
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            DataRow new_dr = new_dt.NewRow();
            if (dt.Rows[i]["Universal"].ToString() == "False")
            {
                filename = DistributorID + "_" + dt.Rows[i]["FilePath"].ToString();
            }
            else
            {
                filename = dt.Rows[i]["FilePath"].ToString();
            }
            string filepath = Server.MapPath("Uploads/Scheme/") + filename;
            if (File.Exists(filepath))
            {
                new_dr["DisplayName"] = dt.Rows[i]["DisplayName"].ToString();
                new_dr["FileName"] = filename;
                new_dr["FilePath"] = filepath;
                new_dt.Rows.Add(new_dr);
            }
        }
    }
    gv7.DataSource = new_dt;
    gv7.DataBind();

How do I solve this problem?

  • 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-06-03T07:28:02+00:00Added an answer on June 3, 2026 at 7:28 am

    Your file path should be start from “http”. Include complete path in the filepath like http://domian-name/foldername/filename with extenssion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I have a file download script that I have written, which reads files from
I become use raw socket and i have this problem: bad file descriptor the
I have problem with session in cakephp.I have one file chat.php that is in
I have the following code for managing file download through django. def serve_file(request, id):
hail, i have a problem to serve file with PHP into client. that when
I need to download a file using Java. I can use this code to
I have a link being generated that looks like so: <a target=_blank title=Test href=file:///c:/test.xls>Test</a>
I have a problem when i try to get the direct download link using
We have a static method in a utility class that will download a file

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.