Create A class first .Here i am assuming that your images are located in a directory called Images
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
public class PhotoManager
{
public PhotoManager()
{
}
public FileInfo[] GetFilesInFolder() {
DirectoryInfo objP =new DirectoryInfo(HttpContext.Current. Server.MapPath("~/Images"));
FileInfo[] objfileCollection = objP.GetFiles();
return objfileCollection;
}
}
Then place a Data list control on the web form : Some thing look like
<asp:datalist id="DataList1" runat="server" repeatcolumns="4" xmlns:asp="#unknown">
<itemtemplate>
<asp:image id="Image1" runat="server" height="50px">
ImageUrl='<%# Eval("Name","~/Images/{0}") %>' Width="50px" />
</asp:image></itemtemplate>
</asp:datalist>
Then place this code in the Code in aspx file:
protected void Page_Load(object sender, EventArgs e)
{
DataList1.DataSource = new PhotoManager().GetFilesInFolder();
DataList1.DataBind();
}
I think this is you are looking