asp转发器数据包

ano*_*Neo 0 .net asp.net repeater databound

我们,在asp转发器服务器控件上不存在数据绑定事件?

我只是想绑定我的所有数据,并在最后创建一个新的ItemTemplate并添加它,但只是什么时候所有数据绑定

ssh*_*how 6

我用它来计算集合中的总小时数.即使我把它放进去FooterTemplate,你也应该能够明白这一点.

<asp:Repeater 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();
    }
}
Run Code Online (Sandbox Code Playgroud)