protected void Page_Load(object sender, EventArgs e) { selectedPoll = eVote.WebClient.Site.selectedPoll; LastVoteLabel.Text = Client.Client.GetLastVote(selectedPoll.ID, HttpContext.Current.User.Identity.Name); var voteOptList = selectedPoll.VoteOptions.ToList(); PollNameLabel.Text = selectedPoll.Name; EndDateLabel.Text = "Ends on: " + selectedPoll.EndDate.ToString(); PollOptionsListView.DataSource = voteOptList; PollOptionsListView.DataBind(); if (FirstChoiceDropDownList.Items.Count < 2) { FirstChoiceDropDownList.DataSource = voteOptList; } if (SecondChoiceDropDownList.Items.Count < 2) { SecondChoiceDropDownList.DataSource = voteOptList; } if (ThirdChoiceDropDownList.Items.Count < 2) { ThirdChoiceDropDownList.DataSource = voteOptList; } FirstChoiceDropDownList.DataBind(); SecondChoiceDropDownList.DataBind(); ThirdChoiceDropDownList.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { selectedPoll = eVote.WebClient.Site.selectedPoll; var voteOptList = selectedPoll.VoteOptions.OrderByDescending(x => x.VoteCount).Select(x => string.Format("{0} - {1} votes", x.Name, x.VoteCount)).ToList(); PollNameLabel.Text = selectedPoll.Name; EndDateLabel.Text = "This poll ended on: " + selectedPoll.EndDate.ToString(); PollOptionsListView.DataSource = voteOptList; PollOptionsListView.DataBind(); }