コード例 #1
0
        protected void InlineResultRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (Type == "Race")
            {
                var achievementHolder = e.Item.FindControl("achievementsHolder") as PlaceHolder;
                if (achievementHolder != null)
                {
                    var achievementManager = new AchievementManager();
                    var race = _raceRepository.GetById(RaceId);
                    if (race != null)
                    {
                        var driverName = DataBinder.Eval(e.Item.DataItem, "Name").ToString();

                        IList<Achievement> achievements =
                            achievementManager.GetAchievementsForRaceEntry(
                                race.Entries.FirstOrDefault(ent => ent.Entrant.Driver.Name == driverName));

                        foreach (var achievement in achievements)
                        {
                            var img = new System.Web.UI.WebControls.Image();
                            img.CssClass = "achievement";
                            img.ImageUrl = "/css/atomicf1/medal_gold_3.png";
                            img.AlternateText = achievement.Description;
                            img.ToolTip = achievement.Description;

                            achievementHolder.Controls.Add(img);
                        }
                    }
                }
            }
        }