在Gridview中显示PDF文件 [英] Display a PDF file in Gridview

查看:58
本文介绍了在Gridview中显示PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在aspx页面中有一个gridview,如下所示

Hi,

I have a gridview in aspx page as below

<asp:GridView ID="grdclnsubforselpat" runat="server" BorderColor="#B1B3B3" BorderWidth="1px"
     CellPadding="2" Width="735px" AutoGenerateColumns="False" EnableModelValidation="True">
     <columns>
         <asp:BoundField DataField="ReferenceNumber" HeaderText="Reference Number" />
         <asp:BoundField DataField="PatientName" HeaderText="Patient Name" />
         <asp:BoundField DataField="PatientDob" HeaderText="Date of Birth " />
         <asp:BoundField DataField="RequestedFrom" HeaderText="Requested From" />
         <asp:HyperLinkField DataTextField="Status" HeaderText="Status" />
         <asp:HyperLinkField DataTextField="Letter" HeaderText="Letter" />
     </columns>

我正在调用一个存储过程,其结果是我保存在一个列表中,并将此数据源作为数据源分配给此gridview进行绑定。

有一个列Letter,它是我数据库中的varbinary。

每当没有值时它会显示为Letter not Available



现在,

我必须将这个varbinary列添加到gridview中,这样当数据库中的字母可用时,该列应显示为Open Letter,一旦我们单击开放字母,DB字段中的varbinary代码应为转换为一封信,应该被视为PDF字母,否则会在列中显示在线不可用的消息





我试过检查列表没有可用并动态添加超链接字段但我不确定如何在前端显示不同的消息以及单击打开pdf。



任何帮助表示赞赏。谢谢你在advacne

I am calling a stored procedure whose result I am saving in a list and assigning as data source to this gridview for binding.
There is a Column "Letter" which is a varbinary in my database.
whenever there is no value it will display as "Letter Not Available"

Now,
I have to add this varbinary column to gridview such that when letter is available in database the column should appear as Open Letter and once we click open letter the varbinary code in the DB field should be converted to a letter and should be viewed as PDF letter otherwise display a message in the column as "Not Available Online"


I tried checking the list for not available and dynamically adding the hyperlink field but I am not sure how to display a different message in front end and on clicking open a pdf.

any help is appreciated. thank you in advacne

推荐答案

GridView的OnRowDatabound事件,只需找到控件并更改文本。



您可以在点击该链接时调用ashx处理程序并在响应对象的帮助下打开pdf。
OnRowDatabound event of GridView, just find the control and change the Text.

You can call an ashx handler on click of that link and open a pdf with the help of response object.


您永远不应该假设客户端的系统支持PDF,这不是一个部分W3标准。如果将PDF作为单独页面请求,则不会有问题。某些系统具有PDF支持,通常采用某些浏览器插件的形式。此类客户端将选择将其显示为页面或保存文件。其他系统只允许用户保存文件,这根本不是问题;用户可以随时查看或打印它;某些系统可能根本没有PDF支持。



如果你想在一些HTML元素中包含PDF,甚至不尝试。相反,您必须解析PDF,以您希望的方式提取结构化数据,并以一种或另一种方式将其映射到HTML。如果当然,生成的HTML可以是表格单元格的内容( GridView 始终以HTML格式呈现为 table 元素)。



您必须在服务器端解析PDF。这是一组可以使用的PDF库参考: http://csharp-source.net/open-source / pdf-libraries



-SA
You should never assume that the client's system supports PDF, which is not a part of W3 standard. It would not be a problem if PDF was requested as a separate page. Some systems have PDF support, usually in the form of some browser plug-ins. Such clients will give a choice to show it as a page or save the file. Other systems will only allow the user to save a file, which is not a problem at all; the user can always view or print it later; some systems may have no PDF support at all.

If you want to have PDF inside some HTML element, don't even try. Instead, you have to parse PDF, extract structured data the way you want and map it to HTML in one or another way. If course, the resulting HTML can be the content of your table cell (GridView is always rendered in HTML as table element).

You have to parse PDF on the server side. This is a set of references to PDF libraries you can use: http://csharp-source.net/open-source/pdf-libraries.

—SA


这篇关于在Gridview中显示PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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