Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview with a hyperlink using templatefield.

ASP.NET
<asp:TemplateField HeaderText="Item Refs" SortExpression="Datapath">
    <EditItemTemplate>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Datapath") %>'></asp:TextBox>
    </EditItemTemplate>
    <ItemTemplate>
        <asp:HyperLink Target="_blank" ID="attachment" runat="server" NavigateUrl='<%# Bind("Datapath") %>' Text="View"></asp:HyperLink>
    </ItemTemplate>
</asp:TemplateField>


result

I have tried IE, Chrome and FF but no luck. the url is location to network folder.

\\web\uploads\147127\BFM-510483-1001\file.pdf


Any idea?
Posted
Comments
ZurdoDev 1-Feb-16 10:17am    
That's because your DataPath is wrong.
r00n3y 1-Feb-16 11:30am    
how can i fix it? thats how its stored in db.
ZurdoDev 1-Feb-16 11:38am    
Implment the RowCreated event, https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcreated(v=vs.110).aspx

Each time a row is created this will fire and you can get access to the hyperlink and change NavigateUrl property to an actual url.
Sinisa Hajnal 1-Feb-16 11:53am    
You have to use proper url in hyperlink. something like file://web/uploads....../whatever.pdf
r00n3y 1-Feb-16 14:43pm    
is there a way to append text to the asp:HyperLink field? Maybe i can add "file:" and see if it works?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900