我有一个GridView,绑定了一个数据源。自动生成了列,数据源中一个列是文件的地址(文件在服务器上的硬盘上 D:\aaa\.a.pdf) 我想单击一行。然后就根据地址打开PDF文件  请问我该怎么做???
谢谢了 我很着急

解决方案 »

  1.   

    b/s?单击可以谈出个窗体操作吧.要是c/s可以直接根据路径调用本机文件
      

  2.   

    把pdf文件拷贝到你网站目录里面,要不 D:\aaa\.a.pdf  是指向客户端的路径,而不是服务器端的路径要不就写一个aspx,把服务器路径当做参数,然后这个aspx来读取这个pdf文件,然后发送到客户端,你必须有读取这个pdf文件的权限,要不aspx出错
      

  3.   

    是B/S的  其实就是想实现<a href="\images\about.gif">dddd</a> 不知道这样能不能打开文件 
      

  4.   

    所有连接都指向文件下载页,把地址传过去。using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.IO;namespace Saga.LiveChain.LiveChainJTGCOA.AssistantWork.MeetingSet
    {
        public partial class SubModule_MeetingSet_DownLoad : System.Web.UI.Page
        {
            public string FileName
            {
                get
                {
                    if (Request.QueryString["FileName"] != null)
                    {
                        return Request.QueryString["FileName"].ToString();
                    }
                    else
                    {
                        return "";
                    }
                }
            }
            public string URL
            {
                get
                {
                    if (Request.QueryString["URL"] != null)
                    {
                        return Request.QueryString["URL"].ToString();
                    }
                    else
                    {
                        return "";
                    }
                }
            }
            protected void Page_Load(object sender, EventArgs e)
            {
                string RandomName = URL;
                string FilePath = Server.MapPath("~/UpLoad/Meeting") + RandomName;
                FilePath = Server.UrlDecode(FilePath);
                if (File.Exists(FilePath))
                {
                    FileInfo fi = new FileInfo(FilePath);
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.Buffer = false;
                    Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Path.GetFileName(FileName), System.Text.Encoding.UTF8));
                    Response.AppendHeader("Content-Length", fi.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(FilePath);
                    Response.Flush();
                    Response.End();
                }
                else
                {
                    Response.Write("<script langauge=javascript>alert('文件不存在!');window.close();</script>");
                    Response.End();
                }
            }
        }
    }
      

  5.   

     <a href="/images/about.gif">dddd </a>
    可以,不过是在浏览器中打开
      

  6.   

    maco_wang  你帖的代码是 我单击后 出现了提示保存吧 其实我就是想用GRIDVIEW显示列表 单击后直接打开PDF
      

  7.   

     哈哈 其实我就是想要这个效果 Response.Redirect("600100:拐点出现,腾飞在即.pdf");
    谢谢各位 结贴了 感谢
      

  8.   


     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
               
                if (e.Row .RowType== DataControlRowType.DataRow)
                {
     e.Row.Attributes.Add("ondblclick", "window.open(\"a.html?id=" + e.Row.Cells[1].Text + "\")");
          // 这个a.html你可以替换成你自己的aspx页面,然后去得传过去的id,e.Row.Cells[1].Text这个你可以换成你想传的任何字段;然后你自己可以随便操作了 ,也就是5楼的代码    
    }