方式一
在aspx页面,写好需要循环输出的内容,一般包含用户自定义控件、服务器控件、Html格式的片段、和<%# Eval("Name")%>这种方式来动态显示获取到得数据列表:
让我们在ItemDataBound事件中赋值:
ProductCellInfo productItem = (ProductCellInfo)e.Item.DataItem;
if (productItem != null)
{
ProductFullNameCell productName;
ImageCell image;
ProductControlCell productControlCell;
foreach (Control sub in e.Item.Controls)
{
productName = sub as ProductFullNameCell;
if (productName != null)
{
productName.InitProductFullName(productItem.Title, productItem.PromotionTitle, DispalyContentLength);
continue;
}
image = sub as ImageCell;
if (image != null)
{
image.InitImageCell2(productItem.ID, productItem.Code, productItem.Name, productItem.ImageUrl, productItem.ImageVersion);
continue;
}
productControlCell = sub as ProductControlCell;
if (productControlCell != null)
{
productControlCell.InitProductControlCell(productItem);
continue;
}
}
}
}
</div>
方式三:
在aspx页面,可以显示设置OnItemDataBound属性,就不用像方式二那样,在cs文件中的OnInit方法中动态绑定,代码如下:
&n