方式一
在aspx頁面,寫好需要循環(huán)輸出的內(nèi)容,一般包含用戶自定義控件、服務(wù)器控件、Html格式的片段、和<%# Eval("Name")%>這種方式來動態(tài)顯示獲取到得數(shù)據(jù)列表:
讓我們在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;
}
}
}
}
this.rptListCell.DataSource = this.List;
this.rptListCell.DataBind();
}
protected void RptAllOnItemDataBound(object sender, RepeaterItemEventArgs e)
{
CategoryInfo category = (CategoryInfo)e.Item.DataItem;
PlaceHolder pHot = e.Item.FindControl("pHot") as PlaceHolder;
PlaceHolder pNew = e.Item.FindControl("pNew") as PlaceHolder;
Literal lit = e.Item.FindControl("literalValidGiftOption") as Literal;
switch (category.PromotionStatus)
{
case "H":
pHot.Visible = true;
break;
case "N":
pNew.Visible = true;
break;
default:
break;
}
lit.Text = category.Name;
}
新聞熱點
疑難解答
圖片精選