示例#1
0
        void rptChildren_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Child child = (Child)e.Item.DataItem;

                Literal litGrade     = (Literal)e.Item.FindControl("litGrade");
                Literal litChildInfo = (Literal)e.Item.FindControl("litChildInfo");

                string childPrefix = string.Empty;

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    if (gli != null)
                    {
                        litGrade.Text = gli.AbbreviatedGrade.Raw;
                        childPrefix   = String.Concat(gli.Name.Raw, ", ");
                    }
                }

                litChildInfo.Text = String.Concat(childPrefix, MembershipHelper.GetLocalizedGender(child.Gender));

                Repeater rptIssues = e.FindControlAs <Repeater>("rptIssues");
                if (child.Issues.Any())
                {
                    var issues = child.Issues.Select(x => (ChildIssueItem)Sitecore.Context.Database.GetItem(x.Key))
                                 .Where(x => x != null);

                    rptIssues.DataSource = issues;
                    rptIssues.DataBind();
                }
            }
        }
示例#2
0
        protected void rptChildren_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.IsItem())
            {
                Domain.Membership.Child child = (Domain.Membership.Child)e.Item.DataItem;

                Literal litGrade = e.FindControlAs <Literal>("litGrade");
                litGrade.Text = string.Empty;

                Literal litChild    = e.FindControlAs <Literal>("litChild");
                string  gradePrefix = string.Empty;

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    if (gli != null)
                    {
                        string abbreviation = gli.AbbreviatedGrade.Rendered;

                        gradePrefix = abbreviation + ", ";

                        litGrade.Text = abbreviation;
                    }
                }

                // TODO: localize gender
                string gender = MembershipHelper.GetLocalizedGender(child.Gender);

                litChild.Text = String.Concat(gradePrefix, gender);

                // Issues
                Repeater rptIssues = e.FindControlAs <Repeater>("rptIssues");
                if (child.Issues.Any())
                {
                    rptIssues.DataSource = child.Issues;
                    rptIssues.DataBind();
                }
            }
        }
示例#3
0
        void lvChildren_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                Child child = (Child)e.Item.DataItem;

                Literal litChild = (Literal)e.Item.FindControl("litChild");

                var grade = child.Grades.FirstOrDefault();
                if (grade != null)
                {
                    GradeLevelItem gli = Sitecore.Context.Database.GetItem(grade.Key);
                    litChild.Text = String.Format("{0}, {1}", gli.Name.Rendered, MembershipHelper.GetLocalizedGender(child.Gender));
                }

                Repeater rptIssues = (Repeater)e.Item.FindControl("rptIssues");
                if (child.Issues.Any())
                {
                    rptIssues.DataSource = child.Issues;
                    rptIssues.DataBind();
                }
            }
        }