希望是绑定到GridView的HyperLink,通过点击看文件..

解决方案 »

  1.   

    这我知道,装ADOBE READER
    我把这个对应里的路径直接帮定到GridView的HyperLink ,不好点击.
    TO: 1L
      

  2.   

    直接绑肯定不行,
    你需要得到你服务的路径
    HttpContext.Current.Request.ApplicationPath
    你文件相对的路径,也许就是218_28160.pdf
    你右击link,看属性,调整一下,正确了就可以了
      

  3.   

            <asp:GridView ID="gvdata" runat="server" AutoGenerateColumns="False" Width="293px" >  
                <Columns>
                    <asp:BoundField DataField="title" HeaderText="标题" />
                    <asp:TemplateField>
                      <ItemTemplate>                        
                        <asp:HyperLink ID="HyperLink1" Text='浏览该PDF文件' NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "name") %>' runat="server"></asp:HyperLink> 
                        </ItemTemplate> 
                    </asp:TemplateField>
                </Columns>
    我把代码帖出来大家看看,帮帮忙
      

  4.   

    //Bind GridView 
        private void Bind()
        {
            string str = "select name from url";
            SqlConnection cn = new SqlConnection(conn);
            SqlDataAdapter da = new SqlDataAdapter(str, cn);
            DataSet ds = new DataSet();
            cn.Open();
            da.Fill(ds);
            gvdata.DataSource = ds;
            gvdata.DataBind();
            cn.Close();
        }
      

  5.   

    我将文件已经上传到C:/Inetpub/wwwroot/File/218_28160.doc
      

  6.   

    你不能在数据库直接存入C:\Inetpub\wwwroot\File\218_28160.pdf这样的路径的.
    这个是你服务器的绝对物理路径.
    在客户端是无法看到的
    要存放的应该是相对路径.这样用户点击的时候,在确认相对路径没有错误的情况下,用户是可以访问到的.
    比如:你的网站根目录是:C:\Inetpub\wwwroot\
    你文件在C:\Inetpub\wwwroot\File\218_28160.pdf
    你保存应该是保存:/File/218_28160.pdf到数据库
    到时候取得的是http://domain.com/file/218_28160.pdf这样就可以访问了.
    不知道是不是指这个问题.