• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

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.
0
techsuppoprt
Asked:
techsuppoprt
  • 3
  • 2
  • 2
1 Solution
 
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
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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
 
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now