Note that there are some explanatory texts on larger screens.

plurals
  1. POBind repeater to a list of files and/or folders
    text
    copied!<p>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? </p> <p>UPDATE: Here's what i have so far, please let me know if there's a better way to do this</p> <p>ListView to display my folders</p> <pre><code>&lt;asp:ListView ID="lvAlbums" runat="server" DataSourceID="odsDirectories"&gt; &lt;asp:ObjectDataSource ID="odsDirectories" runat="server" SelectMethod="getDirectories" TypeName="FolderClass"&gt; &lt;SelectParameters&gt; &lt;asp:QueryStringParameter DefaultValue="" Name="album" QueryStringField="album" Type="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:ObjectDataSource&gt; </code></pre> <p>ListView to display my thumbnails</p> <pre><code>&lt;asp:ListView ID="lvThumbs" runat="server" DataSourceID="odsFiles"&gt; &lt;asp:ObjectDataSource ID="odsFiles" runat="server" SelectMethod="getFiles" TypeName="FolderClass"&gt; &lt;SelectParameters&gt; &lt;asp:QueryStringParameter Type="String" DefaultValue="" Name="album" QueryStringField="album" /&gt; &lt;/SelectParameters&gt; &lt;/asp:ObjectDataSource&gt; </code></pre> <p>And here's FolderClass</p> <pre><code>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 =&gt; (subDir.Name) != "thumbs").ToArray(); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload