protected void BindData(bool showResults) { Poll poll = PollManager.GetPollByID(this.PollID); if (poll != null && poll.Published) { lblPollName.Text = Server.HtmlEncode(poll.Name); lblTotalVotes.Text = string.Format(GetLocaleResourceString("Polls.TotalVotes"), poll.TotalVotes); PollAnswerCollection pollAnswers = poll.PollAnswers; pnlTakePoll.Visible = !showResults; pnlPollResults.Visible = showResults; if (showResults) { dlResults.DataSource = pollAnswers; dlResults.DataBind(); } else { rblPollAnswers.DataSource = pollAnswers; rblPollAnswers.DataBind(); } } else { pnlTakePoll.Visible = false; pnlPollResults.Visible = false; } }
public Poll SaveInfo() { Poll poll = PollManager.GetPollByID(this.PollID); if (poll != null) { poll = PollManager.UpdatePoll(poll.PollID, int.Parse(this.ddlLanguage.SelectedItem.Value), txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, txtDisplayOrder.Value); } else { poll = PollManager.InsertPoll(int.Parse(this.ddlLanguage.SelectedItem.Value), txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, txtDisplayOrder.Value); } return(poll); }
private void BindData() { Poll poll = PollManager.GetPollByID(this.PollID); if (poll != null) { CommonHelper.SelectListItem(this.ddlLanguage, poll.LanguageID); this.txtName.Text = poll.Name; this.txtSystemKeyword.Text = poll.SystemKeyword; this.cbPublished.Checked = poll.Published; this.txtDisplayOrder.Value = poll.DisplayOrder; pnlPollAnswers.Visible = true; PollAnswerCollection pollAnswers = poll.PollAnswers; gvPollAnswers.DataSource = pollAnswers; gvPollAnswers.DataBind(); } else { pnlPollAnswers.Visible = false; } }
protected void dlResults_ItemDataBound(object sender, DataListItemEventArgs e) { Image imgPercentage = (Image)e.Item.FindControl("imgPercentage"); Label lblPercentage = (Label)e.Item.FindControl("lblPercentage"); Poll poll = PollManager.GetPollByID(this.PollID); if (poll != null) { int pollAnswerVoteCount = (int)DataBinder.Eval(e.Item.DataItem, "Count"); int pollTotalVoteCount = poll.TotalVotes; if (pollTotalVoteCount > 0) { double pct = (Convert.ToDouble(pollAnswerVoteCount) / Convert.ToDouble(pollTotalVoteCount)) * Convert.ToDouble(100); lblPercentage.Text = pct.ToString("0.0") + "%"; imgPercentage.Width = Unit.Percentage(pct); } else { lblPercentage.Text = "0%"; imgPercentage.Visible = false; } } }