문제

I GUYS, ASP Repeater Server 컨트롤에 데이터로 설정된 이벤트가 없습니까?

방금 모든 데이터를 바인딩하고 싶습니다. 그리고 끝에 새로운 ItemTemplate을 생성하고 추가 할 수 있지만 모든 데이터가 바인딩 된 모든 데이터가

도움이 되었습니까?

해결책

나는 컬렉션의 총 시간을 계산하기 위해 이것을 사용합니다.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();
    }
}
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top