kode opsætning
HejKender ikke C# så godt så ville høre om nogle kunne hjælpe mig igang, hvis jeg har denne kode til at vise nogle filer i en mappe hvordan skal den så deles op for at kunne virke som asp.net
<asp:GridView ID="gridDirList" runat="server" AutoGenerateColumns="False"
OnSelectedIndexChanged="gridDirList_SelectedIndexChanged"
GridLines="None" CellPadding="0" CellSpacing="1"
DataKeyNames="FullName">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img src="folder.jpg" alt="Folder" />
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField DataTextField="Name" CommandName="Select"
HeaderText="Name" />
<asp:BoundField HeaderText="Size" />
<asp:BoundField DataField="LastWriteTime" HeaderText="Last Modified" />
</Columns>
</asp:GridView>
<asp:GridView ID="gridFileList" runat="server" AutoGenerateColumns="False"
OnSelectedIndexChanged="gridFileList_SelectedIndexChanged"
GridLines="None" CellPadding="0" CellSpacing="1" DataKeyNames="FullName">
<SelectedRowStyle BackColor="#C0fFF" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img src="file.jpg" alt="File" />
</ItemTemplate>
</asp:TemplateField>
<asp:ButtonField DataTextField="Name" CommandName="Select" />
<asp:BoundField DataField="Length" />
<asp:BoundField DataField="LastWriteTime" />
</Columns>
</asp:GridView>
private void ShowDirectoryContents(string path)
{
// Define the current directory.
DirectoryInfo dir = new DirectoryInfo(path);
// Get the files and directories in the current directory.
FileInfo[] files = dir.GetFiles();
DirectoryInfo[] dirs = dir.GetDirectories();
// Show the files and directories in the current directory.
lblCurrentDir.Text = "Currently showing " + path;
gridFileList.DataSource = files;
gridDirList.DataSource = dirs;
Page.DataBind();
// Clear any selection in the GridView that shows files.
gridFileList.SelectedIndex = -1;
// Keep track of the current path.
ViewState["CurrentPath"] = path;
}
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
ShowDirectoryContents(Server.MapPath("."));
}
}
protected void cmdUp_Click(object sender, System.EventArgs e)
{
string path = (string)ViewState["CurrentPath"];
path = Path.Combine(path, "..");
path = Path.GetFullPath(path);
ShowDirectoryContents(path);
}
protected void gridDirList_SelectedIndexChanged(object source, EventArgs e)
{
// Get the selected directory.
string dir = (string)gridDirList.DataKeys[gridDirList.SelectedIndex].Value;
// Now refresh the directory list to
// show the selected directory.
ShowDirectoryContents(dir);
}