0

Web ページにグリッドビューがあり、列の 1 つが「参照番号」になっています。参照番号は、サーバー上の 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>
4

1 に答える 1

0

Reference NumberフィールドをTemplateFieldではなく に変更する必要がありBoundFieldます。これにより、そのフィールドにハイパーリンクを配置できます。

GridView コントロールで TemplateFields を使用して読み取る

そこから、 を使用しHttpHandlerて PDF ファイルを作成し、それをユーザーにストリーミングすることをお勧めします。これには 2 つの利点があります。

  1. ポストバックがないため、ユーザーはグリッド表示で自分の場所を失うことはありません。
  2. これにより、ユーザーはアプリケーションとは別に PDF を簡単に表示および/または保存できます。
于 2013-07-23T17:08:06.733 に答える