I am new to ASP.NET and C#. I am trying to retrieve all images from folder and show it on page, but it\'s only selecting one image.
My ASP.NET code:
The problem is in this statement:
Image.ImageUrl = Convert.ToString(dr["Image_Path"]);
What does this statement do? It assigns each image path value to only one Image.ImageUrl. So, the Image.ImageUrl will hold the last assigned image path. The result is only one picture will be displayed. This is not what you want.
What you want is: show all pictures --> assign each image path to each Image.ImageUrl --> dynamically create the Image and add it to the form. So, instead of writing that statement, you should do something like:
Image img = new Image();
img.ImageUrl = dr["Image_Path"].ToString();
img.AlternateText = "Test image";
form1.Controls.Add(img);
The code is not tested. Just focus on the idea. You can do it like this, or use the repeater, or your own way, it's up to you.
Feel free to ask me if you find something unclear :)