appending a text string to the DataNavigateURLField property

J

Jim in Arizona

This has something to do with my previous post titled "virtual directory and
hyperlink file path issue (listed and linked paths don't match)".

In the aspx page, I have this datagrid code:

--
<asp:DataGrid id="dgFiles" runat="server" Font-Names="Tahoma"
AutoGenerateColumns="false" AlternatingItemStyle-BackColor="AliceBlue"
HeaderStyle-BackColor="Beige" HeaderStyle-ForeColor="Black"
HeaderStyle-font-size="10pt" HeaderStyle-Font-Bold="true">

<Columns>

<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name"
HeaderText="File Name" />

<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="File Size"
ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />

</Columns>

</asp:DataGrid>
--

The hyperlink is showing a path such as
http://mysite.com/companyfiles/filename.doc and instead should be showing
http://mysite.com/companyfiles/files/filename.doc. I'm trying to append the
files directory name within the HyperLinkColumn code above in a way like
this:

<asp:HyperLinkColumn DataNavigateUrlField='<%Response.Write("/files/") &
"Name" %>' DataTextField="Name" HeaderText="File Name" />

so that the URL comes out right. I can't seem to find the proper way of
doing it without causing an error.

This whole thing has become very frustrating in that it appears to be a
glitch!

In the code behind, when I have code like this:

Dim dirinfo As New DirectoryInfo(Server.MapPath("./files/"))
dgFiles.DataSource = dirinfo.GetFiles()
dgFiles.DataBind()

The files inside the files directory are displayed fine but the hyperlink is
pointing to the directory above it where the aspx file resides!

Any ideas anyone?

TIA,
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top