Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 是否从gridview链接打开PDF?_Asp.net_Vb.net_Gridview - Fatal编程技术网

Asp.net 是否从gridview链接打开PDF?

Asp.net 是否从gridview链接打开PDF?,asp.net,vb.net,gridview,Asp.net,Vb.net,Gridview,我的网页上有一个gridview,其中一列是“参考号”。参考号表示服务器上pdf文件的名称。是否可以将此列更改为超链接列,以便在单击行上的参考号时打开pdf?例如,他们单击ReferenceNumber 123456,它会打开pdf\server\folder\123456.pdf。多谢各位 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSou

我的网页上有一个gridview,其中一列是“参考号”。参考号表示服务器上pdf文件的名称。是否可以将此列更改为超链接列,以便在单击行上的参考号时打开pdf?例如,他们单击ReferenceNumber 123456,它会打开pdf\server\folder\123456.pdf。多谢各位

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
    CellPadding="4" DataSourceID="SqlDataSource1" 
    ForeColor="#333333" GridLines="None">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
        <asp:CommandField ShowSelectButton="True" />
        <asp:BoundField DataField="ReferenceNumber" HeaderText="Reference #" 
            SortExpression="ReferenceNumber" />
        <asp:BoundField DataField="Teaching_Hospital_Name" HeaderText="Teaching Hospital Name" 
            SortExpression="Teaching_Hospital_Name" />
        <asp:BoundField DataField="Date_of_Payment" 
            HeaderText="Date" SortExpression="Date_of_Payment" />
        <asp:BoundField DataField="Physician_First_Name" 
            HeaderText="First Name" SortExpression="Physician_First_Name" />
        <asp:BoundField DataField="Physician_Last_Name" 
            HeaderText="Last Name" SortExpression="Physician_Last_Name" />
        <asp:BoundField DataField="Recipient_Primary_Business_Street_Address_Line_1" 
            HeaderText="Address 1" 
            SortExpression="Recipient_Primary_Business_Street_Address_Line_1" />
        <asp:BoundField DataField="Recipient_City" HeaderText="City" 
            SortExpression="Recipient_City" />
        <asp:BoundField DataField="Recipient_State" HeaderText="State" 
            SortExpression="Recipient_State" />
        <asp:BoundField DataField="Recipient_Zip_Code" HeaderText="Zip" 
            SortExpression="Recipient_Zip_Code" />
        <asp:BoundField DataField="Total_Amount_of_Payment" HeaderText="Total_Amount" 
            SortExpression="Total_Amount_of_Payment" />
    </Columns>
    <EditRowStyle BackColor="#999999" />
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#E9E7E2" />
    <SortedAscendingHeaderStyle BackColor="#506C8C" />
    <SortedDescendingCellStyle BackColor="#FFFDF8" />
    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>

您需要将
参考编号
字段更改为
模板字段
,而不是
边界字段
,这将允许您在该字段中放置超链接

阅读

因此,我建议使用
HttpHandler
构建PDF文件并将其流式传输给用户。这有两个好处:

  • 没有回发,因此用户不会丢失其在网格显示中的位置
  • 它允许用户轻松查看和/或将PDF与应用程序分开保存