protected void InitialiseControl() { var sourceReference = GetSourceReference(); var dataAdapterFactory = new RatingDataAdapterFactory(sourceReference); var dataAdapter = dataAdapterFactory.GetAdapter(Portal, Request.RequestContext); if (RatingInfo == null) { RatingInfo = dataAdapter.GetRatingInfo(); if (RatingInfo == null) { throw new Exception("Error getting Rating Info"); } } var userRating = dataAdapter.SelectUserRating(); var visitorRating = dataAdapter.SelectVisitorRating(VisitorID); switch (RatingType) { case "vote": VoteControl.Visible = EnableRatings; VoteControl.SourceID = SourceID; VoteControl.YesCount = RatingInfo.YesCount; VoteControl.NoCount = RatingInfo.NoCount; if (userRating != null) { int userVote; if (userRating.MaximumValue == userRating.Value) { userVote = (int)VoteValue.Yes; } else if (userRating.MinimumValue == userRating.Value) { userVote = (int)VoteValue.No; } else { userVote = (int)VoteValue.Unvoted; } VoteControl.UserVote = userVote; } else if (visitorRating != null) { int userVote; if (visitorRating.MaximumValue == visitorRating.Value) { userVote = (int)VoteValue.Yes; } else if (visitorRating.MinimumValue == visitorRating.Value) { userVote = (int)VoteValue.No; } else { userVote = (int)VoteValue.Unvoted; } VoteControl.UserVote = userVote; } VoteControl.UpdateDisplay(); break; default: RatingControl.Visible = EnableRatings; RatingControl.SourceID = SourceID; RatingControl.AverageRating = RatingInfo.AverageRating; RatingControl.RatingCount = RatingInfo.RatingCount; if (userRating != null) { RatingControl.UserRating = userRating.Value; } else if (visitorRating != null) { RatingControl.UserRating = visitorRating.Value; } RatingControl.UpdateDisplay(); break; } }