datalist对象repPix捆定当前目录下的所有子目录的名称后我想让这个子目录的名称变成一个联接然后
点击这个目录以后就可以浏览这个子目录里面的子目录。我该怎么做?
<a href=photoalbum.aspx?dir= "& <%# Container.DataItem("Dirlink")%>" >
<%# Container.DataItem("DirName")%></a>
<%@ Page Language="VB" Explicit="True" Debug="True"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Data"%>
<script runat="server">
Sub page_load(Sender As Object,E As EventArgs) Dim pdir As String = Request.Params("path")
dim strPath As String =Request("dir")
If strpath="" or pdir = strpath then If pdir = "" Then
pdir = "."
End If
pdir = ResolveURL(pdir) If Right(pdir,1) <> "/" Then
pdir = pdir & "/"
End If
lblPath.Text = pdir
up_dir.InnerHtml="根目录"
DisplayFolder() Else if strPath <> "" Then lblpath.text = strpath
up_dir.innerhtml="<a href=photoalbum.aspx?dir="& pdir &">向上</a>"
DisplayFolder()
End If
new_dir.InnerHtml="<a href=new_folder1.aspx?dir=" & lblpath.text & ">添加目录</a>"
upload_file.InnerHtml="<a href=upload_file2.aspx?dir=" & lblpath.text & ">上传文件</a>"
end subSub DisplayFolder()
Dim strPath As String
Dim dnfCur As DirectoryInfo
Dim dtbDirs As DataTable
Dim dnfSub As DirectoryInfo
Dim rowPix As DataRow
Dim dtbPix As DataTable
Dim clmPix As DataColumn
Dim fnfCur As FileInfo
Dim strExt As String
strPath = lblPath.Text
dnfCur = New DirectoryInfo(server.mappath(strPath))
dtbDirs = new DataTable("sublist")
dtbDirs.Columns.Add("DirName", _
System.Type.GetType("System.String"))
dtbdirs.columns.add("dirlink", _
System.Type.GetType("System.String"))
For each dnfSub in dnfCur.GetDirectories
If left(dnfSub.Name,1) <> "_" Then
rowPix = dtbDirs.NewRow()
rowPix("DirName") = dnfSub.Name
rowPix("Dirlink") = (server.mappath(strpath) & dnfsub.name )
dtbDirs.Rows.Add(rowPix)
End If
Next repPix.DataSource = dtbDirs
repPix.DataBind
End Sub
</script><html>
<head>
<title>PhotoAlbum</title>
<link rel="stylesheet" type="text/css" href="normal.css">
<link rel="stylesheet" type="text/css" href="small.css">
</head>
<body><table border="0" cellspacing="0" cellpadding="0" width="1024"><tr>
<td><asp:label id="lblPath" runat="server" /></td>
<td><span id="new_dir" runat="Server"/></td>
<td><span id="upload_file" runat="Server"/></td>
<td><span id="up_dir" runat="Server"/></td>
</tr></table><hr align="left" noshade>
<form method="POST" style="margin:0" runat="server">
</form>
<asp:DataList id="repPix" runat="server"
BorderColor="black"
CellPadding="10"
Font-Name="Verdana"
Font-Size="8pt"
border="1"
RepeatDirection="Horizontal"
RepeatColumns="4"
> <HeaderStyle BackColor="#999999">
</HeaderStyle> <ItemStyle BackColor="Gainsboro"
HorizontalAlign="center"
VerticalAlign="middle">
</ItemStyle>
<HeaderTemplate> Items </HeaderTemplate>
<ItemTemplate >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href=photoalbum.aspx?dir= "& <%# Container.DataItem("Dirlink")%>" >
<%# Container.DataItem("DirName")%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList><hr noshade height="1" align="left">
</body>
</html>
点击这个目录以后就可以浏览这个子目录里面的子目录。我该怎么做?
<a href=photoalbum.aspx?dir= "& <%# Container.DataItem("Dirlink")%>" >
<%# Container.DataItem("DirName")%></a>
<%@ Page Language="VB" Explicit="True" Debug="True"%>
<%@ Import Namespace="System.IO"%>
<%@ Import Namespace="System.Data"%>
<script runat="server">
Sub page_load(Sender As Object,E As EventArgs) Dim pdir As String = Request.Params("path")
dim strPath As String =Request("dir")
If strpath="" or pdir = strpath then If pdir = "" Then
pdir = "."
End If
pdir = ResolveURL(pdir) If Right(pdir,1) <> "/" Then
pdir = pdir & "/"
End If
lblPath.Text = pdir
up_dir.InnerHtml="根目录"
DisplayFolder() Else if strPath <> "" Then lblpath.text = strpath
up_dir.innerhtml="<a href=photoalbum.aspx?dir="& pdir &">向上</a>"
DisplayFolder()
End If
new_dir.InnerHtml="<a href=new_folder1.aspx?dir=" & lblpath.text & ">添加目录</a>"
upload_file.InnerHtml="<a href=upload_file2.aspx?dir=" & lblpath.text & ">上传文件</a>"
end subSub DisplayFolder()
Dim strPath As String
Dim dnfCur As DirectoryInfo
Dim dtbDirs As DataTable
Dim dnfSub As DirectoryInfo
Dim rowPix As DataRow
Dim dtbPix As DataTable
Dim clmPix As DataColumn
Dim fnfCur As FileInfo
Dim strExt As String
strPath = lblPath.Text
dnfCur = New DirectoryInfo(server.mappath(strPath))
dtbDirs = new DataTable("sublist")
dtbDirs.Columns.Add("DirName", _
System.Type.GetType("System.String"))
dtbdirs.columns.add("dirlink", _
System.Type.GetType("System.String"))
For each dnfSub in dnfCur.GetDirectories
If left(dnfSub.Name,1) <> "_" Then
rowPix = dtbDirs.NewRow()
rowPix("DirName") = dnfSub.Name
rowPix("Dirlink") = (server.mappath(strpath) & dnfsub.name )
dtbDirs.Rows.Add(rowPix)
End If
Next repPix.DataSource = dtbDirs
repPix.DataBind
End Sub
</script><html>
<head>
<title>PhotoAlbum</title>
<link rel="stylesheet" type="text/css" href="normal.css">
<link rel="stylesheet" type="text/css" href="small.css">
</head>
<body><table border="0" cellspacing="0" cellpadding="0" width="1024"><tr>
<td><asp:label id="lblPath" runat="server" /></td>
<td><span id="new_dir" runat="Server"/></td>
<td><span id="upload_file" runat="Server"/></td>
<td><span id="up_dir" runat="Server"/></td>
</tr></table><hr align="left" noshade>
<form method="POST" style="margin:0" runat="server">
</form>
<asp:DataList id="repPix" runat="server"
BorderColor="black"
CellPadding="10"
Font-Name="Verdana"
Font-Size="8pt"
border="1"
RepeatDirection="Horizontal"
RepeatColumns="4"
> <HeaderStyle BackColor="#999999">
</HeaderStyle> <ItemStyle BackColor="Gainsboro"
HorizontalAlign="center"
VerticalAlign="middle">
</ItemStyle>
<HeaderTemplate> Items </HeaderTemplate>
<ItemTemplate >
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href=photoalbum.aspx?dir= "& <%# Container.DataItem("Dirlink")%>" >
<%# Container.DataItem("DirName")%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList><hr noshade height="1" align="left">
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货