protected void btnSaveChoice_Click(object sender, EventArgs e) { Page.Validate("choice"); if (Page.IsValid) { if (String.IsNullOrEmpty(Request.QueryString["pollChoiceID"])) { int curr_poll_id = (Int32)ViewState["vsPollID"]; qSoc_PollChoice2 choice = new qSoc_PollChoice2(); choice.PollID = curr_poll_id; choice.Choice = txtChoice.Text; choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; choice.FeedbackTitle = txtFeedbackTitle.Text; choice.FeedbackDescription = txtFeedbackText.Text; choice.FeedbackUrl = txtFeedbackLink.Text; if (rblIsCorrect.SelectedValue == "Yes") choice.Correct = "Yes"; choice.Insert(); int new_poll_choice_id = choice.PollChoiceID; BindChoices(); plhEditChoice.Visible = false; } else { int curr_poll_id = (Int32)ViewState["vsPollID"]; int curr_poll_choice_id = Convert.ToInt32(Request.QueryString["pollChoiceID"]); qSoc_PollChoice2 choice = new qSoc_PollChoice2(curr_poll_choice_id); choice.Choice = txtChoice.Text; choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; choice.FeedbackTitle = txtFeedbackTitle.Text; choice.FeedbackDescription = txtFeedbackText.Text; choice.FeedbackUrl = txtFeedbackLink.Text; if (rblIsCorrect.SelectedValue == "Yes") choice.Correct = "Yes"; choice.Update(); BindChoices(); plhEditChoice.Visible = false; } } }
protected int createNewChoice(int curr_poll_id, string choice, bool is_correct) { int new_poll_id = 0; qSoc_PollChoice2 new_choice = new qSoc_PollChoice2(); new_choice.PollID = curr_poll_id; new_choice.Choice = choice; if (is_correct == true) new_choice.Correct = "Yes"; new_choice.ChoiceMediaHTML = txtMediaChoiceHTML.Text; new_choice.FeedbackTitle = txtFeedbackTitle.Text; new_choice.FeedbackDescription = txtFeedbackText.Text; new_choice.FeedbackUrl = txtFeedbackLink.Text; new_choice.Insert(); new_poll_id = new_choice.PollChoiceID; return new_poll_id; }