I am not entirely certain what you question is, but I believe you were wanting to know how to accomplish the layout you specified that looks like:
first row ( image1 , image2 , image3 )
second row (name1 , name2 , name3)
third row (image4 , image5 ,image6 )
fourth row ( name4 , name5 , name6 )
To do that use the following code.
html.Append("<table border="1">");
int itemCount = 0;
StringBuilder sbImageRow = new StringBuilder();
StringBuilder sbNameRow = new StringBuilder();
foreach (DataRow row in dt.Rows)
{
itemCount++;
int windex = row["Image"].ToString().IndexOf("/");
sbImageRow.Append("<td><img src='" + row["Image"].ToString().Substring(windex) + "' height='60' width='60' </></td>");
sbNameRow.Append("<td>" + row["Name"] + "</td>");
if(itemCount % 3 == 0)
{
html.Append("<tr>");
html.Append(sbImageRow.ToString());
html.Append("</tr>");
html.Append("<tr>");
html.Append(sbNameRow.ToString());
html.Append("</tr>");
itemCount = 0;
sbImageRow = new StringBuilder();
sbNameRow = new StringBuilder();
}
}
if(itemCount != 0)
{
for(int i = itemCount; i < 3; i++)
{
sbImageRow.Append("<td></td>");
sbNameRow.Append("<td></td>");
}
html.Append("<tr>");
html.Append(sbImageRow.ToString());
html.Append("</tr>");
html.Append("<tr>");
html.Append(sbNameRow.ToString());
html.Append("</tr>");
}
html.Append("</table>");
Again, not sure if this what you were looking for and this isn't the most eloquent solution, but it would accomplish what you want. Please let me know if you have any questions.