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 8083741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:34:19+00:00 2026-06-05T17:34:19+00:00

want to open pdf file when a user clicks on hyperlink shown in gridview

  • 0

want to open pdf file when a user clicks on hyperlink shown in gridview column.The name of the file is taken from first column of the gridview where file titles are stored.

hovering over hyperlink in gridview shows file link, but when clicked it doesnot open pdf file,

protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
{

 if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hlink = (HyperLink)e.Row.FindControl("HL");
            string url = "~/Docs/" + e.Row.Cells[1].Text +".pdf";
            hlink.NavigateUrl = url;
            hlink.Text = "Read";
        } 
 }

The following error comes when hyperlink is clicked, as it is not able to open pdf file.

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable

which event is called when hyperlink is clicked in a gridview, maybe pdf application is to be opened there. Please suggest. Thanks in adavance.

  • 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-05T17:34:21+00:00Added an answer on June 5, 2026 at 5:34 pm

    The error suggests that your file doesn’t exist. What you should do is to forego the concatenation that you do and instead include the whole name of the file (including extension) in your data source and use it (or even the entire path). The reason you want to do it that way is because you may have modified/formatted/encoded the cell text strictly for aesthetic purposes. You could have even added some embedded html to style it.

    I would imagine it would look something like this:

    protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
    
     if (e.Row.RowType == DataControlRowType.DataRow)
         {
                DataRow row = ((System.Data.DataRowView)e.Row.DataItem).Row;
                HyperLink hlink = e.Row.FindControl("HL") as HyperLink;
                if (hlink!=null)
                {
                    string url = string.Format("~/Docs/{0}",row["FileName"]);
                    hlink.NavigateUrl = url;
                    hlink.Text = "Read";
                }
         } 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open a PDF file in a new browser window when user
I want to open a PDF file from a jsp. The jsp and the
I want to be able to open a pdf file from my application without
I want to open pdf file in webview but the scenario is different here,
I have a iframe that i want to open pdf's into from a list
I want to open a file whose name should be given as string to
I want open pdf file directly without asking open,save options(prompt window).In this temppath is
Hello I want to open PDF file in Android app, I found this apv
I just want to open a pdf file and not to use it. If
I wan't to open a pdf file on Xcode using phone gap[corodova 1.7.0]. Is

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.