Click here to Skip to main content
15,895,370 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to display multiple Images from a folder which is present in my project in asp.net using c#.

Its something like Images of templates which would be displayed and hence then the user can see them and download them.

Can anyone help me with this ??

Thanks
Posted
Comments
Sandeep Mewara 8-Jan-13 5:09am    
What have you tried so far? Where are you stuck?
Ram Mehta 8-Jan-13 5:18am    
Hello Sandeep

I have tried with things like this :


<asp:DataList ID="dlQLImages" runat="server">

<itemtemplate>

<img id="Img1" src='<%# string.Format("~/Images/{0}", DataBinder.Eval(Container.DataItem,"Name")) %>'

height="250" width="400" runat="server" />






and the C# code behind is

protected void Button1_Click(object sender, EventArgs e)
{

DirectoryInfo diImages = new DirectoryInfo(Server.MapPath("~/Image/"));


ArrayList alImages = new ArrayList();
// GetFiles method doesn't allow us to filter for multiple
// file extensions, so we must find images in four steps
// Feel free to add new or remove existing extension to
// suit your needs
alImages.AddRange(diImages.GetFiles("*.gif"));
alImages.AddRange(diImages.GetFiles("*.jpg"));
alImages.AddRange(diImages.GetFiles("*.jpeg"));
alImages.AddRange(diImages.GetFiles("*.bmp"));
alImages.AddRange(diImages.GetFiles("*.png"));

dlQLImages.DataSource = alImages;
dlQLImages.DataBind();

//string dir = @"C:\Users\John\Documents\Visual Studio 2010\WebSites\WebSite1\Image" ;

//DirectoryInfo dirinf = new DirectoryInfo(dir);
//FileInfo[] files = null;

//files = dirinf.GetFiles("*.jpg");

////double sim;

//foreach (FileInfo f in files)
//{

// string imgPath = "Images/" + files[0];
// Image1.ImageUrl = "~/" + imgPath;

// string imgPath1 = "Images/" + files[1];
// Image2.ImageUrl = "~/" + imgPath1;



//}



}

Thanks jOy

But what I am looking for is that my images are present in the folder and then from that I want to retrieve them all.
 
Share this answer
 
1> you simply inserted image name in your database when it is uploading..

2> after that you simply execute your query in to database and got the all Image name

3> after getting those data in your data table you can bind repeater by your data table.


if is it help full then please mark as answer.. =)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900