I am developing a ASP.NET Web site and am looking to add a hyperlink or something similar to a repeater that will retrieve the path directory from a database table to PDF documents, so that when the user clicks the hyperlink they will be able to download the PDF File. Is this possible using a repeater control, I have tried putting the following code in my .aspx page but i guess i need some code behind it in my cs page to work?

<asp:Hyperlink ID="Hyperlink1" runat="server" NavigateUrl='<%  # Eval("columnname") %>'>Hyperlink</asp:Hyperlink>

Any help would be great

Recommended Answers

All 4 Replies

post your databinding code, yes you can use repeater or datalist.

<asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource2">
    <ItemTemplate>
    <p>Weight:</p>
    <%# Eval("Weight") %>
    <p>Pile Type:</p>
    <%# Eval("Pile") %>
    <p>Materials used:</p>
    <%# Eval("Material") %>
    <asp:Hyperlink ID="Hyperlink1" runat="server" NavigateUrl='<% # Eval("Specification") %>'>Hyperlink</asp:Hyperlink>
       
    </ItemTemplate>
   
    </asp:Repeater>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT Name, Weight, Pile, Material, Specification, seriesID FROM tblcarpetSeries WHERE (seriesID = @seriesID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="seriesID" QueryStringField="seriesID" />
        </SelectParameters>
    </asp:SqlDataSource>

I should mention that i am using a Master - Details page, this code resides in my details page. I am looking to use a hyperlink control that will retrieve the folder path to the PDF documents, these paths are stored in the tblcarpetSeries (in the Specification column), meaning that when the user clicks the hyperlink for each record they will be able to download the PDF File that corresponds to that exact record in the database table.

I know that this is not elegant code, but i am just starting out in ASP.NET Development. If there is a better way of achieving the same result using another method then i am willing to look into that.

Thanks in advance

i have managed to link to the PDF document using the following


<a href="./<% # Eval("Specification") %>"><%# Eval("Specification") %></a>


However when i click on the link to the document in the web browser all i get in Firefox is an empty dialog box and in Internet Explorer its just a blank page. Do i need to enter code in the C# page so that the web app knows which content type it is?

i will give you a working sample when i get home.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.