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.cbShowOnHomePage.Checked = poll.ShowOnHomePage; if (poll.StartDate.HasValue) { this.ctrlStartDate.SelectedDate = poll.StartDate; } if (poll.EndDate.HasValue) { this.ctrlEndDate.SelectedDate = poll.EndDate; } this.txtDisplayOrder.Value = poll.DisplayOrder; pnlPollAnswers.Visible = true; var pollAnswers = poll.PollAnswers; gvPollAnswers.DataSource = pollAnswers; gvPollAnswers.DataBind(); } else { pnlPollAnswers.Visible = false; } }
public Poll SaveInfo() { Poll poll = PollManager.GetPollById(this.PollId); DateTime?startDate = ctrlStartDate.SelectedDate; DateTime?endDate = ctrlEndDate.SelectedDate; if (startDate.HasValue) { startDate = DateTime.SpecifyKind(startDate.Value, DateTimeKind.Utc); } if (endDate.HasValue) { endDate = DateTime.SpecifyKind(endDate.Value, DateTimeKind.Utc); } if (poll != null) { poll = PollManager.UpdatePoll(poll.PollId, int.Parse(this.ddlLanguage.SelectedItem.Value), txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, cbShowOnHomePage.Checked, txtDisplayOrder.Value, startDate, endDate); } else { poll = PollManager.InsertPoll(int.Parse(this.ddlLanguage.SelectedItem.Value), txtName.Text, txtSystemKeyword.Text, cbPublished.Checked, cbShowOnHomePage.Checked, txtDisplayOrder.Value, startDate, endDate); } return(poll); }
protected void BindData(bool showResults) { var 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); var 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) { var imgPercentage = (Image)e.Item.FindControl("imgPercentage"); var lblPercentage = (Label)e.Item.FindControl("lblPercentage"); var 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; } } }