我在gridview中有一个锚标签来打开pdf文件,但链接无法正常工作 [英] i have an anchor tag inside gridview to open pdf file but the link is not working its not opening file

查看:63
本文介绍了我在gridview中有一个锚标签来打开pdf文件,但链接无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview中有一个锚标签打开pdf文件,但链接无法正常工作它没有打开文件



我的代码是:

< asp:gridview id =   gvRpt runat =   server autogeneratecolumns =   false width =   99% borderstyle =   
borderwidth = 1px cellpadding = 2 cssclass = mGrid allowpaging = true pagesize = 10
style = margin-top:0px onpageindexchanging = gvRpt_PageIndexChanging onrowdatabound = gvRpt_RowDataBound >
< columns>
< asp:templatefield headertext = Sr.No。 headerstyle-wrap = < span class =code-string> false >
<&的ItemTemplate GT;
<%#Container.DataItemIndex + 1 %>
< / itemtemplate >
< itemstyle cssclass = GridDataC wrap = false > < / itemstyle >
< / asp:templatefield >
< asp:boundfield datafield = < span class =code-string> BankName headertext = 银行名称 < SP class =code-keyword>>
< itemstyle cssclass = GridDataL > < / itemstyle >
< / asp:boundfield >
< asp:boundfield datafield = < span class =code-string> BankCode headertext = 银行代码 < span class =code-keyword>>
< itemstyle cssclass = GridDataC > < / itemstyle >
< / asp:boundfield >
< asp:boundfield datafield = FileName headertext = 文件名 > ;
< itemstyle cssclass = GridDataL > < / itemstyle >
< / asp:boundfield >
< asp:templatefield headertext = 下载 <跨度class =code-keyword>>
< itemtemplate>
< b>< a id = lnkDownload target = _ blank href = D:/Lubna/ReportGeneration_WinApp/ReportGeneration_WinApp/DownloadPDF/HDF/HDFReport_27Aug2014_051145.pdf runat = server>下载< / a > < / b >
< / itemtemplate >
< itemstyle cssclass = GridDataC换行= < span class =code-string> false > < / itemstyle >
< / asp:templatefield >
< asp:boundfield datafield = Statusdesc headertext = 状态 />
< asp:boundfield datafield = CreatedDate headertext = 创建日期 dataformatstring = {0:dd-MMM-yyyy} />
< / >
< / asp:gridview >





当我点击下载时它不会打开文件。文件名和位置是正确的我已经测试了它甚至与简单的html页面只有锚标签它在html页面工作正常。 gridview有问题吗?请帮我如何从gridview里面的锚标签打开pdf文件。



提前谢谢。

解决方案

在你的解决方案中创建一个目录并将所有需要的PDF文件存储在其中。

然后只提供该目录的路径。

希望你能得到它。

i have an anchor tag inside gridview to open pdf file but the link is not working its not opening file

my code is:

<asp:gridview id="gvRpt" runat="server" autogeneratecolumns="false" width="99%" borderstyle="None"
           borderwidth="1px" cellpadding="2" cssclass="mGrid" allowpaging="true" pagesize="10"
           style="margin-top: 0px" onpageindexchanging="gvRpt_PageIndexChanging" onrowdatabound="gvRpt_RowDataBound">
           <columns>
               <asp:templatefield headertext="Sr. No." headerstyle-wrap="false">
                   <itemtemplate>
                       <%#Container.DataItemIndex+1 %>
                   </itemtemplate>
                   <itemstyle cssclass="GridDataC" wrap="false"></itemstyle>
               </asp:templatefield>
               <asp:boundfield datafield="BankName" headertext="Bank Name">
                   <itemstyle cssclass="GridDataL"></itemstyle>
               </asp:boundfield>
               <asp:boundfield datafield="BankCode" headertext="Bank Code">
                   <itemstyle cssclass="GridDataC"></itemstyle>
               </asp:boundfield>
               <asp:boundfield datafield="FileName" headertext="File Name">
                   <itemstyle cssclass="GridDataL"></itemstyle>
               </asp:boundfield>
               <asp:templatefield headertext="Download">
                   <itemtemplate>
                       <b><a id="lnkDownload" target="_blank" href="D:/Lubna/ReportGeneration_WinApp/ReportGeneration_WinApp/DownloadPDF/HDF/HDFReport_27Aug2014_051145.pdf" runat="server" >Download</a></b>
                   </itemtemplate>
                   <itemstyle cssclass="GridDataC" wrap="false"></itemstyle>
               </asp:templatefield>
               <asp:boundfield datafield="Statusdesc" headertext="Status" />
               <asp:boundfield datafield="CreatedDate" headertext="Created Date" dataformatstring="{0:dd-MMM-yyyy}" />
           </columns>
       </asp:gridview>



when I click on download it doesn't open file. file name and location is proper I have tested it even with simple html page with only anchor tag it is working fine in html page. is there issue with gridview ?? please help me how to open pdf file from anchor tag which is inside gridview.

Thanks in advance.

解决方案

make one directory in your solution and store all needed PDF file in it.
then give just path of that directory.
hope you can get it.


这篇关于我在gridview中有一个锚标签来打开pdf文件,但链接无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆