//前台代码
<
asp
:
DataList
DataKeyField="Id" ID="DataList1"
OnItemDataBound="DataList1_ItemDataBound" runat="server" >
<ItemTemplate>
<table width="170" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/h01.gif" width="175" height="8"></td>
</tr>
<tr>
<td valign="top" background="images/h02.gif">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td align="center" class="t05">
<a href='twostage.aspx?id=<%# Eval("Id")%>' class="mon">
<%# Eval("Name")%>
</a>
</td>
</tr>
<tr>
<td align="center">
<asp:HyperLink ID="HyperLink1" Target="_blank" runat="server">
<asp:Image ID="Image1" Width="80" Height="99" runat="server" />
</asp:HyperLink>
</td>
</tr>
</table>
<asp:DataList ID="DataList2" runat="server">
<HeaderTemplate>
<table width="100%" border="0" style="text-align:left;" cellpadding="3" cellspacing="0">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td height="21" background="images/line.gif">
<img src="images/icon02.gif" width="5" height="7">
<a href='fivestage.aspx?id=<%# Eval("GoodsId") %>' target="_blank"><%# FHY.BLL.Uti.SqlText(Eval("GoodsName").ToString(),10,true,true) %></a>
</td>
</tr>
<tr>
<td height="21" class="mon" background="images/line.gif">
价格:¥<%# JiaGe(Eval("GoodsId"), Eval("JiageFanWei"))%> </a>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td height="21" align="right" background="images/line.gif">
<img src="images/icon03.gif" width="27" height="12"></td>
</tr>
</table>
</FooterTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table width="170" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="images/h03.gif" width="175" height="8"></td>
</tr>
</table>
</ItemTemplate>
<ItemStyle VerticalAlign="Top" />
</asp:DataList>
//后台代码
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
int id = Convert.ToInt32(DataList1.DataKeys[e.Item.ItemIndex]);
GoodsTuiJianDal tuijiandal = new GoodsTuiJianDal();
DataView dv = tuijiandal.GetList_VW1(id).Tables[0].DefaultView;
if (dv.Count > 0)
{
Image titlepic = (Image)e.Item.FindControl("Image1");
titlepic.ImageUrl =FHY.BLL.Uti.ImageUrl(dv[0]["PicSrc"].ToString());
HyperLink titleHyperLink = (HyperLink)e.Item.FindControl("HyperLink1");
titleHyperLink.NavigateUrl = "~/fivestage.aspx?id=" + dv[0]["GoodsId"].ToString();
}
DataList read = (DataList)e.Item.FindControl("DataList2");
read.DataSource = dv;
read.DataBind();
}
}