C# OnItemDataBound不';不显示绑定的项目的完整列表
我有一个中继器,上面有一个C# OnItemDataBound不';不显示绑定的项目的完整列表,c#,asp.net,repeater,C#,Asp.net,Repeater,我有一个中继器,上面有一个OnItemDataBound事件。出于某种原因,中继器绑定了三个项目。但我尝试了下面的方法,它只在页面顶部写“2”。中继器本身确实显示了这三个项目,但是OnDataBound事件中的这个循环没有看到最后一个项目。为什么? protected void colourRepeater_ItemBound(object sender, RepeaterItemEventArgs e) { int count = 0; foreach (RepeaterIte
OnItemDataBound
事件。出于某种原因,中继器绑定了三个项目。但我尝试了下面的方法,它只在页面顶部写“2”。中继器本身确实显示了这三个项目,但是OnDataBound
事件中的这个循环没有看到最后一个项目。为什么?
protected void colourRepeater_ItemBound(object sender, RepeaterItemEventArgs e)
{
int count = 0;
foreach (RepeaterItem item in rptAssoicatedProducts.Items)
{
count++;
}
Response.Write(count.ToString());
}
请尝试以下方法:
int count = 0;
protected void colourRepeater_ItemBound(object sender, RepeaterItemEventArgs e)
{
count++;
Response.Write("Items so far : " + count.ToString());
}
编辑:
触发
ItemDataBound
事件时,RepeaterItem
尚未链接到中继器。。。只有相关的数据是。是的,但我想访问项中的控件,即Literal litsomething=((Literal)e.item.FindControl(“litsomething”);算了吧!