<table width="585" border="0" cellspacing="0" cellpadding="0">
<asp:Repeater ID="rpList" runat="server">
<ItemTemplate>
<tr style="width:585">
<td width="195" align="center">
<img alt="" width="185" height="136" src='Manage/CompanyInfoManage<%# Eval("Url1") %>'/>
</td>
<td width="195" align="center">
<img alt="" width="185" height="136" src='Manage/CompanyInfoManage<%# Eval("Url2") %>'/>
</td>
<td width="195" align="center">
<img alt="" width="185" height="136" src='Manage/CompanyInfoManage<%# Eval("Url3") %>'/>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
=============================.cs代码部分=========================================
调用:rpList.DataSource = ConvertTable(dtPicture);//显示图片
rpList.DataBind();
public List<CompanyPhoto> ConvertTable(DataTable dt)
{
List<CompanyPhoto> list = new List<CompanyPhoto>();
int i = 0;
CompanyPhoto photo = new CompanyPhoto();
foreach (DataRow row in dt.Rows)
{
string url = row["Url"].ToString();
if (i == 0)
{
photo = new CompanyPhoto();
photo.Url1 = url;
}
else if (i == 1)
{
photo.Url2 = url;
}
else if (i == 2)
{
photo.Url3 = url;
list.Add(photo);
}
if (i != 2)
{
i++;
}
else
{
i = 0;
}
}
if (i != 0)
{
list.Add(photo);
}
return list;
}
public class CompanyPhoto
{
public string Url1 { get; set; }
public string Url2 { get; set; }
public string Url3 { get; set; }
}