Hi i am trying to make a repeater with two arrays, but i don't know how to do it or if its possible. What i am trying to accomplish is to get this html:
<ul>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li><a href="#"><img src="images/gallery/thumbs/2.jpg" data-large="<%# Container.DataItem %>" alt="image02" data-description="A plaintful story from a sistering vale" /></a>
</li>
...
</ItemTemplate>
</asp:Repeater>
</ul>
The li tags have to be generated dynamically.To be more specific i want the imgs src to take elements from second list, data large to take the elements from the first list and data description to take file name from the element of the first or second.And to generate li tag for every iteration. This is the code behind:
string[] original = Directory.GetFiles(Server.MapPath(@"images\gallery\projects\original\"));
string[] thumbs = Directory.GetFiles(Server.MapPath(@"images\gallery\projects\thumbs\"));
List<string> originalL = new List<string>();
foreach (string s in original)
{
originalL.Add("images/gallery/projects/original/" + Path.GetFileName(s));
}
Repeater1.DataSource = originalL;
Repeater1.DataBind();
Before i have used controls to make tags but with this html i cant achieve that. I don't know how to add the attributes to inner img tag.If someone can help me make the control or give me some pointers on how to make the repeater take multiple arrays it will be of great help. If it could be made with controls it would be better , but any solution is good. Thanks in advance.
P.s sorry for the mistakes i was really tired last night.
Best Solution
The following code has been debugged and works perfectly!
Codebehind:
HTML:
I am unsure where you are going to retrieve the descriptions from, but you can use this to get the IDs from a directory: