示例#1
0
        protected void Answer_Click(object sender, EventArgs e)
        {
            context = new QuestionaryEntities(srcUri);
            answer answer = new answer();

            if (answerList1.SelectedValue != "" || answerList2.SelectedValue != "" || answerList3.SelectedValue != "" ||
                answerList4.SelectedValue != "" || answerList5.SelectedValue != "" || answerList6.SelectedValue != "" ||
                answerList7.SelectedValue != "" || age.Text != "")
            {
                answer.answer1 = Int32.Parse(answerList1.SelectedValue);
                answer.answer2 = Int32.Parse(answerList2.SelectedValue);
                answer.answer3 = Int32.Parse(answerList3.SelectedValue);
                answer.answer4 = Int32.Parse(answerList4.SelectedValue);
                answer.answer5 = Int32.Parse(answerList5.SelectedValue);
                answer.answer6 = Int32.Parse(answerList6.SelectedValue);
                answer.answer7 = Int32.Parse(answerList7.SelectedValue);
                answer.idSex = Int32.Parse(sexList.SelectedValue);
                answer.age = Int32.Parse(age.Text);
                answer.email = email.Text;

                context.AddToanswers(answer);
                context.SaveChanges();

                message.ForeColor = Color.Green;

                message.Text = "Ваш ответ добавлен";
                message.Visible = true;
            }
            else
            {
                message.ForeColor = Color.Red;
                message.Text = "Заполните все необходимые данные!";

                message.Visible = true;
            }
        }
示例#2
0
 private void loadSexes()
 {
     context = new QuestionaryEntities(srcUri);
     var sexes = from a in context.sexes
                      select new
                      {
                          Id = a.id,
                          Title = a.title
                      };
     sexList.DataTextField = "Title";
     sexList.DataValueField = "Id";
     sexList.DataSource = sexes;
     sexList.DataBind();
 }