Solved

Open file with hyperlink in Gridview

Posted on 2006-07-19
2
4,982 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
ID: 17136384
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
ID: 17136403
Just checked - Firefox opens file too
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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