<%@ Import Namespace="System.IO" %>
<html>
<title>DataGrid 巧用实现 目录浏览!!!</title>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E){
ArrayList ar = new ArrayList();
Directory[] dirs = Directory.GetDirectoriesInDirectory(Server.MapPath("http://www.cuoxin.com/"));
foreach (Directory dir in dirs) {
foreach (File f in dir.GetFiles("*.aspx")) //如果是 想要 列出别的类型的文件,只要修改这个就可以了
{
ar.Add(f.Name);
}
}
dg.DataSource = ar;
dg.DataBind();
}
</script>
</head>
<body>
<form method="post" runat="server">
<asp:DataGrid
Id="dg"
Runat="Server"
headerstyle-backcolor="#666699"
headerstyle-forecolor="#FFFFFF"
itemstyle-backcolor ="#EEEEEE"
alternatingitemstyle-backcolor="#FFFFFF"
alternatingitemstyle-forecolor="#000000"
/>
</form>
</body>