Help with displaying images in a table / gridview

Hi Experts!
I need some help please. I'm trying to think of the best way to populate all pictures from the folder to the page as a little photo viewer. The perfect result would be displaying a DataGrid or a 4x4 table with image thumbnails populated of every picture that's in a certain folder.
Can I possibly throw file names from the folder into the DataSet and then fill the DataGrid or is there a way to dynamically fill the table and enable the "paging" ability?
Thank you in advance.
LVL 1
techsuppoprtAsked:
Who is Participating?
 
REA_ANDREWCommented:
Going to the efficiency levels I would create say a FileSystem DataSource object and further than that Create a PagedFileSystemDataSource.  There is some work for you there and surajguptha has a good point.

A quick search on Google reveals a couple of attempts by people to create such a DataSource which thinking about it could prove very useful if it were extended to be paged:

http://www.codeproject.com/useritems/FolderContentsDataSource.asp

Andrew
0
 
surajgupthaCommented:
>> 4* 4 table means you will be able to display 16 pics max. / dynamically fill the table and enable the "paging" ability?

Are you looking to display every picture in the selected folder in a page?
0
 
techsuppoprtAuthor Commented:
Exactly  
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
REA_ANDREWCommented:
here is a quick example for you.

Andrew

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (FileInfo fi in new DirectoryInfo(Server.MapPath("Images")).GetFiles())
        {
            if (fi.Extension == ".jpg")
            {
                Image i1 = new Image();
                i1.Width = 100;
                i1.Height = 100;
                i1.ImageUrl = "Images/"+fi.Name;
                this.Page.Form.Controls.Add(i1);
            }
        }
    }
}
0
 
REA_ANDREWCommented:
how you construct your container is up to you. Here I simply add the images to the screen but only constraining their size.  You could build on this by using the GDI+ and manipulating the images physical sizee and quality. and maybe for example stick a watermark on there.

Andrew
0
 
surajgupthaCommented:
If the number of pictures are large, displaying all the pictures in there might be too much. I am curious, what are you trying to do? Are you just trying to display all the pictures as thumbnails when the folder is openned?
0
 
techsuppoprtAuthor Commented:
Thank you for your comments. FIrst solution is pretty much what I came up with myself but it doesn't really work because it's a bit too simple and just displays a list of pictures.
I need to end up with somethign like this:
http://hubblesite.org/gallery/wallpaper/
List of Hyperlink pics with  the paging ability.

Andrew, have you had any experience with that control that you posted by any chance ? It mentions that I  need to reference the evenlogdatasource.dll file but I can't figure out where to get it. The only dll that the project provides is foldercontentsdatasource.dll.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.