onitemdatabound="Repeater1_ItemDataBound">
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = e.Item.DataItem as DataRowView;
if (row["NickName"].ToString().Length > 4)
{
Label label = e.Item.FindControl("LabelName") as Label;
label.ForeColor = Color.Red;
}
}
}
服务端控件数据绑定时属性必须用单引号''
还可以参考