Link to home
Start Free TrialLog in
Avatar of talentium
talentium

asked on

Open file with hyperlink in Gridview

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>
ASKER CERTIFIED SOLUTION
Avatar of Ramuncikas
Ramuncikas
Flag of Lithuania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just checked - Firefox opens file too