Solved

Open file with hyperlink in Gridview

Posted on 2006-07-19
2
4,929 Views
Last Modified: 2012-06-27
Hi,
My project is to display content from an oracle database table in a Gridview,
one of the field "filename" in the table give me the name of the file I would like to open through an hyperlink.
I just found the necessary code to setup one of the column in the gridview as hyperlink,
unfortunately the link does not open the file.
by example, the file is called
Johson Peter fee.doc and is stored in a network share "P:\Client_L-Z\Johson Peter fee.doc" and the filename in oracle table is "Johson Peter fee.doc" (VARCHAR, 255)
when I click on the hyperlink, the address in IE is shown as P:\Client_L-Z\Johnson%20Peter%20fee.doc
and the file does not open...if I replace the %20 by a blank (as in the oracle table) the file opens correctly...

I probably miss something but where ?

thanks for your help

this is the code

        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="FILEID" DataSourceID="SqlDataSource2" Width="100%" Font-Size="10pt">
            <Columns>
                <asp:BoundField DataField="FILEID" HeaderText="FILEID" ReadOnly="True" SortExpression="FILEID" Visible="False" />
                <asp:BoundField DataField="DESCRIPT" HeaderText="Type" SortExpression="DESCRIPT" >
                    <ControlStyle Font-Size="10pt" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Event">
                <ItemTemplate>
                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format("P:/Client_L-Z/{0}", DataBinder.Eval(Container.DataItem,"FILENAME")) %>' Text="Go to event"></asp:HyperLink>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="FILEDESCRIPTION" HeaderText="File Description" SortExpression="FILEDESCRIPTION" >
                    <ControlStyle Font-Size="10pt" />
                </asp:BoundField>
                <asp:BoundField DataField="PEOPLEID" HeaderText="PEOPLEID" SortExpression="PEOPLEID" Visible="False" />
            </Columns>
        </asp:GridView>
0
Comment
Question by:talentium
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 125 total points
Comment Utility
If you use IE as a default browser this will do a trick:
...
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format("file:///P:/Client_L-Z/{0}", DataBinder.Eval(Container.DataItem,"FILENAME")) %>' Text="Go to event"></asp:HyperLink>
...
0
 
LVL 14

Expert Comment

by:Ramuncikas
Comment Utility
Just checked - Firefox opens file too
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now