本文介绍了ASP中继器数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,在ASP转发器服务器控件上不存在数据绑定事件吗?
I guys, isn't present databound event on asp repeater server control?
我只想绑定我的所有数据,最后创建一个新的ItemTemplate并添加它,但只是何时绑定所有数据
I just want to bind all my data, and at the end creates a new ItemTemplate and add it, but just when is all data binded
推荐答案
我用它来计算集合中的总小时数。即使我将其放在 FooterTemplate
中,您也应该能够明白这一点。
I use this for calculating total hours in the collection. Even though I put it into the FooterTemplate
, you should be able to get the point.
< asp:中继器ID = rptRecords runat = server OnItemDataBound = rptRecords_ItemDataBound>
protected void rptRecords_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Footer)
{
int totalHours = 0;
foreach (RepeaterItem item in ((Repeater)sender).Items)
{
Label lblRowHours = (Label)item.FindControl("lblHours");
if (lblRowHours != null)
totalHours += Convert.ToInt32(lblRowHours.Text);
}
((Label)e.Item.FindControl("lblHoursTotal")).Text = totalHours.ToString();
}
}
这篇关于ASP中继器数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!