I have created a static aspx page with the following code:
<div class="container">
<div class="contain" id="subdiv" runat="server">
<input type="checkbox" id="cb1" runat="server" />
<label for="cb1">
<img src="Images/download_image.jfif" runat="server" id="imagesrc"/>
<label>some text</label>
</label>
</div>
</div>
Currently, I only have one image on the UI and I'm attempting to manually increase the count like this:
for (int i = 0; i <= 5; i++)
{
Image img = new Image();
img.ImageUrl = "~/Images/download_image.jfif";
subdiv.Controls.Add(img);
}
The code above is not working. The images are supposed to act like checkboxes with label captions. However, the number of images should be based on data from a SQL table, and all images are the same. How can I access the image inside the div element and display it based on the count from the code behind so that all CSS and JS scripts will still be applied? Any help would be appreciated.