Hi all -- I've been trying to get a list of files in a directory to list using the code from http://aspnet.4guysfromrolla.com/articles/052803-1.aspx
The code compiles and runs, but no table appears on the page (or in the page html) -- I think it may have to do with the databind(), but I've tried everything to test/correct this and can't get any output:
<%@ Page Language="VB" AutoEventWireup="false" debug="true" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim articleList as New DataGrid
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
articleList.DataSource = dirInfo.GetFiles()
articleList.DataBind()
End Sub
</script>
<html>
<head runat="server">
<title>Test File Listings</title>
</head>
<body>
<aspataGrid runat="server" id="articleList" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>
<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>
</aspataGrid>
</body>
</html>
Could it be an issue with the server set-up? The only change I made to the sample code was declaring articleList, since it would not compile otherwise...
The code compiles and runs, but no table appears on the page (or in the page html) -- I think it may have to do with the databind(), but I've tried everything to test/correct this and can't get any output:
<%@ Page Language="VB" AutoEventWireup="false" debug="true" %>
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim articleList as New DataGrid
Dim dirInfo as New DirectoryInfo(Server.MapPath(""))
articleList.DataSource = dirInfo.GetFiles()
articleList.DataBind()
End Sub
</script>
<html>
<head runat="server">
<title>Test File Listings</title>
</head>
<body>
<aspataGrid runat="server" id="articleList" AutoGenerateColumns="False">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name"></asp:HyperLinkColumn>
<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>
</aspataGrid>
</body>
</html>
Could it be an issue with the server set-up? The only change I made to the sample code was declaring articleList, since it would not compile otherwise...