I have a datatable (dtFav) with 2 columns - path(string) & location(string).
This table can have 0 to 5 rows.
There are 5 divs on the aspx page, each with the foll. structure
<div id="div1" runat="server">
<asp:image id="image1" runat="server"/>
<asp:hyperlink id="fav1" runat="server"></asp:hyperlink>
</div>
Row1 of dtFav will have the content for div1 and so on...eg:
image1.ImageUrl = dr["path"];
fav1.NavigateUrl = dr["location"];
So the code will be something like:
int i=0;
foreach(DataRow dr in dtFav.Rows)
{
i=i+1;
if(i==1)
{
image1.ImageUrl = dr["path"];
fav1.NavigateUrl = dr["location"];
}
else if(i==2)
{
image2.ImageUrl = dr["path"];
fav2.NavigateUrl = dr["location"];
}
else....
}
I know there will be an elegant way to acheive this. Can this be done by using Ienumerable. I have no clue how to move forward. Please advice.