Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to open this documents using HyperLinkField in a GridView?
    primarykey
    data
    text
    <p>I am a new ASP.NET developer and I am trying to develop a page called Useful Library that will contain many things such as useful presentations and pdf documents. I have a folder in the Server called <strong>(Useful Resources)</strong> and I put all those useful presentations and documents in it. I have the following table in my database:</p> <pre><code>UsefulResources Table: ID, Category, Title, URL, Uploaded Date, Hits </code></pre> <p>The reason of designing this table is to organize the resources. I want now to be able to browse or download these documents. ***For Example, I have presentation called (AP Presentation) that has: ***ID = 5 and URL = AP Prsentation.pptx******</p> <p><em>My ASP.NET code:</em> </p> <pre><code>&lt;asp:HyperLinkField DataNavigateUrlFields="ID,URL" DataNavigateUrlFormatString="Useful Resources/URL={0}" DataTextField="Title" HeaderText="Title" /&gt; </code></pre> <p>I have a problem with this part and I don't know how to fix it to be able to open or download this presentation, <strong>so how to do that?</strong></p> <p>And for your information, <strong>the page called (Library.aspx)</strong> and I don't have any code-behind</p> <p><strong>UPDATE:</strong></p> <p>The link that I have right now is the following: pmvt/msa/pssp/Useful%20Resources/ID=5</p> <p><em>By the way, this is an intranet web-based application so you will not be able to access it using this link.</em></p> <p>And I am getting the following error: <img src="https://i.stack.imgur.com/glBZf.png" alt="enter image description here"></p> <p><strong>UPDATE #2:</strong> Here's my ASP.NET code with SqlDataSource:</p> <pre><code>&lt;asp:SqlDataSource ID="Sql_Reports" runat="server" ConnectionString="&lt;%$ ConnectionStrings:testConnectionString %&gt;" SelectCommand="SELECT [ID], [Title], [URL], [UploadedDate] FROM [UsefulResources] WHERE ([Category] = @Category) ORDER BY [UploadedDate] DESC"&gt; &lt;SelectParameters&gt; &lt;asp:ControlParameter ControlID="Label1" Name="Category" PropertyName="Text" Type="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; &lt;asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" CellPadding="4" DataSourceID="Sql_Reports" ForeColor="#333333" GridLines="None" Width="100%"&gt; &lt;FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt; &lt;RowStyle BackColor="#E3EAEB" /&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title"&gt; &lt;ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;asp:HyperLinkField DataNavigateUrlFields="URL" DataNavigateUrlFormatString="Useful Resources?URL={0}" DataTextField="Title" HeaderText="Title" /&gt; &lt;asp:BoundField DataField="UploadedDate" DataFormatString="{0:MMM yyy}" HeaderText="UploadedDate" SortExpression="UploadedDate"&gt; &lt;ItemStyle HorizontalAlign="Center" Wrap="False" Width="100px" /&gt; &lt;/asp:BoundField&gt; &lt;/Columns&gt; &lt;PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /&gt; &lt;SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /&gt; &lt;HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /&gt; &lt;EditRowStyle BackColor="#7C6F57" /&gt; &lt;AlternatingRowStyle BackColor="White" /&gt; &lt;/asp:GridView&gt; </code></pre> <p>I am still getting the link as <strong><em>pmvt/msa/pssp/Useful%20Resources/?URL=Electrical%20safety.ppt</em></strong>. What I should do to remove <strong><em>(?URL=)</em></strong> from that link in order to get the link working.</p> <p><strong>UPDATE #2:</strong></p> <p>Here's the script for create the table in the database with its data:</p> <pre><code>/****** Object: Table [dbo].[UsefulResources] Script Date: 08/06/2012 07:08:15 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[UsefulResources]( [ID] [int] IDENTITY(1,1) NOT NULL, [Category] [varchar](max) NULL, [Title] [varchar](max) NULL, [URL] [nvarchar](max) NULL, [UploadedDate] [datetime] NULL, [Hits] [int] NULL, CONSTRAINT [PK_UsefulResources] PRIMARY KEY CLUSTERED ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO SET ANSI_PADDING OFF GO SET IDENTITY_INSERT [dbo].[UsefulResources] ON INSERT [dbo].[UsefulResources] ([ID], [Category], [Title], [URL], [UploadedDate], [Hits]) VALUES (1, N'PowerPoint Presentations', N'PMOD', N'Electrical safety.ppt', CAST(0x0000A0A000000000 AS DateTime), 1) INSERT [dbo].[UsefulResources] ([ID], [Category], [Title], [URL], [UploadedDate], [Hits]) VALUES (2, N'Word Documents', N'Fire Drill Evaluation', N'Fire Drill Evaluation.docx', CAST(0x0000A0A300000000 AS DateTime), 1) SET IDENTITY_INSERT [dbo].[UsefulResources] OFF </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload