Tutorials to .com


ASP.NET Development Articles


Can't Find What You're Looking For?

Tutorials to .com » Dotnet » Development » Using DataGrid to achieve the directory browser

Using DataGrid to achieve the directory browser

Print View , by: iSee ,Total views: 5 ,Word Count: 266 ,Date: Sun, 23 Aug 2009 Time: 10:08 AM

/ *
Bean products are produced
technical points such as tofu http://www.asp888.net reprint information, please retain the copyright
* /
asp + We all know that can bind the DataGrid to bind ADO to XML, did not think even the directory structure can be bound! Do not believe, will depend on

<% @ Import Namespace = "System.IO"%>
<html>
Using the realization of <title> DataGrid Directory Browsing! ! ! </ title>
<script language="C#" runat="server">
void Page_Load (Object Src, EventArgs E) (
ArrayList ar = new ArrayList ();
Directory [] dirs = Directory.GetDirectoriesInDirectory (Server.MapPath ("/"));
foreach (Directory dir in dirs) (
foreach (File f in dir.GetFiles ( "*. aspx")) / / If you want to list other types of files, as long as you can change the
(
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>

Author: tofu (original)


Google
 

Rating: Not yet rated

Comments

No comments posted.