protected void Page_Load(object sender, EventArgs e)
 {
     MyPollSystemEntities context = new MyPollSystemEntities();
     var questions = context.Questions.ToList();
     this.GridView.DataSource = questions;
     this.DataBind();
 }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     MyPollSystemEntities context = new MyPollSystemEntities();
     var questions = context.Questions.Include("Answers").OrderBy(q => Guid.NewGuid());
     this.ListViewPolls.DataSource = questions.Take(3).ToList();
     this.DataBind();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     int questionId = Convert.ToInt32(Request.Params["questionId"]);
     MyPollSystemEntities context = new MyPollSystemEntities();
     Question question = context.Questions.Find(questionId);
     this.LiteralQuestion.Text = question.QuestionText;
     this.RepeaterAnsweers.DataSource = question.Answers.ToList();
     this.RepeaterAnsweers.DataBind();
 }
        protected void Unnamed_Command(object sender, CommandEventArgs e)
        {
            int answerId = Convert.ToInt32(e.CommandArgument);
            MyPollSystemEntities context = new MyPollSystemEntities();
            Answer answer = context.Answers.Find(answerId);
            answer.Votes++;
            context.SaveChanges();

            Response.Redirect("ShowVotingResults.aspx?questionId=" +
                answer.QuestionId);
        }