protected void Button1_Click(object sender, EventArgs e) { ExamDbModel.ExamDbEntities x = new ExamDbModel.ExamDbEntities(); int index = int.Parse(RadioButtonList1.SelectedValue); ExamDbModel.Question que=new ExamDbModel.Question(); que.QuestionText= txtQuestion.Text; que.ChapterID= int.Parse(txtChapter.SelectedValue); x.AddToQuestions(que); x.SaveChanges(); switch (index) { case 0: //Blank ExamDbModel.QuestionBlank blank = new ExamDbModel.QuestionBlank(); blank.CorrectAnswer = BlankAns.Text; blank.QuestionID = que.QuestionID; x.AddToQuestionBlanks(blank); x.SaveChanges(); Label1.Text = "BlankRequestion is added"; //Fill the grid BindBlanks(); break; case 1: //Bool ExamDbModel.QuestionBool boool = new ExamDbModel.QuestionBool(); boool.QuestionID = que.QuestionID; boool.Answer1 = BoolAns1.Text; boool.Answer2 = BoolAns2.Text; boool.CorrectAnswer = BoolAns.Checked; x.AddToQuestionBools(boool); x.SaveChanges(); Label1.Text = "BoolQequestion is added"; BindBool(); break; case 2: //MCQ ExamDbModel.QuestionMcq mcq = new ExamDbModel.QuestionMcq(); mcq.QuestionID = que.QuestionID; mcq.Answer1 = McaA1.Text; mcq.Answer2 = McqA2.Text; mcq.Answer3 = McqA3.Text; mcq.Answer4 = McqA4.Text; mcq.CorrectAnswer = McqCorrect.Text; x.AddToQuestionMcqs(mcq); x.SaveChanges(); Label1.Text = "MCQQuestion is added"; BindMCQ(); break; } }
/// <summary> /// Deprecated Method for adding a new object to the QuestionBlanks EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToQuestionBlanks(QuestionBlank questionBlank) { base.AddObject("QuestionBlanks", questionBlank); }
/// <summary> /// Create a new QuestionBlank object. /// </summary> /// <param name="questionID">Initial value of the QuestionID property.</param> public static QuestionBlank CreateQuestionBlank(global::System.Int32 questionID) { QuestionBlank questionBlank = new QuestionBlank(); questionBlank.QuestionID = questionID; return questionBlank; }