Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid Hyperlink to subfolder items

Status
Not open for further replies.

Jeepers321

Technical User
Oct 17, 2000
17
US
I am currently using this code here;

ON MY CODE PAGE

Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   Dim dirInfo As new DirectoryInfo(Server.MapPath(""))
   DataGrid1.DataSource = dirInfo.GetFiles("images/*.jpg")
   DataGrid1.DataBind()

End Sub

ON MY ASPX PAGE

Code:
<%@ Page Language="vb" AutoEventWireup="False" Codebehind="WebForm2.aspx.vb" Inherits="WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
   <HEAD>
      <title>WebForm2</title>
      <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
      <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
      <meta name="vs_defaultClientScript" content="JavaScript">
      <meta name="vs_targetSchema" content="[URL unfurl="true"]http://schemas.microsoft.com/intellisense/ie5">[/URL]
   </HEAD>

   <body MS_POSITIONING="GridLayout">

      <form id="Form1" method="post" runat="server">

         <asp:DataGrid Runat="server" ID="DataGrid1" AutoGenerateColumns="False">

            <Columns>

[COLOR=red]               <asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>[/color]

               <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" DataFormatString="{0:d}"></asp:BoundColumn>

               <asp:BoundColumn DataField="Length" HeaderText="File Size" DataFormatString="{0:#,### bytes}"></asp:BoundColumn>

            </Columns>
         </asp:DataGrid>
      </form>
   </body>
</HTML>

My problem is here; DataNavigateUrlField="Name"

The hyperlink is incorrect because of the location of the aspx file.
Is there a way for me to fix this without having to store my page in the images folder.
Any help would be greatly appreciated.
Thanks
 
<asp:HyperLinkColumn
NavigateURL='<%# "foldername/" & DataBinder.Eval(Container.dataitem,"name")%>'
DataTextField="Name" HeaderText="File Name">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top