I’m using hyperlink in gridview.
With NavigateUrl I can link my PDF documents from my project directory /pdf/ArchiveCode.pdf.
Right now I have two PDF documents in my directory (first document 020001.0001.0001.pdf and second document 100410.0001.0001.pdf), but in the hyperlink column from gridView are shown all links with text value ‘PDF’.
----------------------------------------
| PDF | ArchiveCode | - Headers from gridView
----------------------------------------
| PDF | 020001.0001.0001 |
----------------------------------------
| PDF | 100410.0001.0001 |
----------------------------------------
| PDF | 020001.0131.0441 |
----------------------------------------
| PDF | 020001.0005.0007 |
----------------------------------------
| PDF | 020001.0003.0002 |
----------------------------------------
...
Because I have just two PDF documents is it possible to hide other links (dead links) that are not used from the gridview and to activate the link when I create new document in my project directory?
Here is the code for the HyperLink and for ArchiveCode column:
<asp:TemplateField HeaderText="PDF">
<ItemTemplate>
<asp:HyperLink ID="PDFHyperLink" Target="_blank" runat="server" Text="PDF" NavigateUrl = '<%# "~/pdf/" + Eval("ArchiveCode") + ".pdf" %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ArchiveCode">
<ItemTemplate>
<asp:Label ID="lblKod" Text='<%# Eval("ArchiveCode") %>' runat="server"/>
</ItemTemplate>
</asp:TemplateField>
Thank to your comments I finally fix my little problem and I can control the Hyperlink TEXT in GridView using simple bool condition. In my database table I add new boolean column with the name “activePDF”. After that in my GridView I modify the asp:HyperLink:
Hope this helps others.