I would like to create a very simple image gallery. I am trying to figure out how to bind a Repeater to some kind of a custom object that would return back a list of files and/or folders. Can somebody point me in the right direction?
UPDATE: Here's what i have so far, please let me know if there's a better way to do this
ListView to display my folders
<asp:ListView ID="lvAlbums" runat="server" DataSourceID="odsDirectories">
<asp:ObjectDataSource ID="odsDirectories" runat="server" SelectMethod="getDirectories" TypeName="FolderClass">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="" Name="album" QueryStringField="album" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
ListView to display my thumbnails
<asp:ListView ID="lvThumbs" runat="server" DataSourceID="odsFiles">
<asp:ObjectDataSource ID="odsFiles" runat="server" SelectMethod="getFiles" TypeName="FolderClass">
<SelectParameters>
<asp:QueryStringParameter Type="String" DefaultValue="" Name="album" QueryStringField="album" />
</SelectParameters>
</asp:ObjectDataSource>
And here's FolderClass
public class FolderClass
{
private DataSet dsFolder = new DataSet("ds1");
public static FileInfo[] getFiles(string album)
{
return new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("/albums/" + album)).GetFiles();
}
public static DirectoryInfo[] getDirectories(string album)
{
return new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("/albums/" + album)).GetDirectories()
.Where(subDir => (subDir.Name) != "thumbs").ToArray();
}
}