Newbie: Databind not working?

drr

Joined
Oct 20, 2006
Messages
1
Reaction score
0
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>

<asp:DataGrid 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>
</asp:DataGrid>

</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...
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top