Bind Image Gallery without Database using Directory Info

Hello Everybody,

Here I am gonna show you how to bind Image Gallery without using database with directory info(using image directory with image extension).
It's very simple like 1,2,3 here is the code:

.aspx page:


   

    Image Gallery
   
   
   

    <%# Eval("Name", "{0}") %>
   
   
   
    
.aspx.cs code:


using System.IO; (namespace)

protected void BindGallery()
    {
        DirectoryInfo dir = new DirectoryInfo(Server.MapPath("~/Images/"));
        dlGetPhotos.DataSource = dir.GetFiles("*.jpg");
        dlGetPhotos.DataBind();
    }

I hope you will enjoy it..
Cheers,
ved

Comments