Hi *.*,
As a continuation of my previous post. Now i'm binding images from folder.
Code
private class ImageFileInfo
{
public string FileName { get; set; }
}
public void limage()
{
string imgFolder = HttpContext.Current.Request.PhysicalApplicationPath + @"img\";
string[] fileEntries = Directory.GetFiles(imgFolder);
List<ImageFileInfo> mylist = new List<ImageFileInfo>();
foreach (string fName in fileEntries)
{
string d = System.IO.Path.GetFileName(fName);
mylist.Add(new ImageFileInfo { FileName = d });
}
dtagrid.DataSource = mylist;
dtagrid.DataBind();
}
On HTML
<asp:DataList ID="dtagrid" runat="server" RepeatColumns="5" RepeatDirection="Horizontal">
<ItemTemplate>
<li><a href='img/<%# Eval("FileName") %>'>
<img src='img/<%# Eval("FileName") %>' alt="" /></a></li>
</ItemTemplate>
</asp:DataList>
Stay Tune...
Have a nice day... 'N happy Coding :)
No comments:
Post a Comment