示例#1
0
        protected void btnLoad_Click(object sender, EventArgs e)
        {
            ListItem li = ddlQuestions.SelectedItem;

            if (li.Text == "New Question")
            {
                //Initialize new question, clear theseAnswers and all extraneous text boxes;
                Guid gQuestionID = Guid.NewGuid();
                txtQuestionID.Text   = gQuestionID.ToString();
                txtQuestionText.Text = "";
                theseAnswers.Clear();
                answerList.Value     = "";
                txtAnswerID.Text     = "";
                txtAnswerText.Text   = "";
                txtSortOrder.Text    = "";
                lbAnswers.DataSource = theseAnswers;
                lbAnswers.DataBind();
            }
            else
            {
                theseQuestions = DeserialzeQuestions();
                classes.Question thisQuestion = theseQuestions.Find(delegate(classes.Question myQuestion) { return(myQuestion.QuestionID == new Guid(ddlQuestions.SelectedValue)); });
                if (thisQuestion != null)
                {
                    txtQuestionID.Text            = thisQuestion.QuestionID.ToString();
                    txtQuestionText.Text          = thisQuestion.QuestionText;
                    ddlQuestionType.SelectedValue = thisQuestion.QuestionTypeID.ToString();
                }
                classes.SQLCode mySQL = new classes.SQLCode();
                theseAnswers.Clear();
                //if we have a question, look for answers for that question
                if (!string.IsNullOrEmpty(txtQuestionID.Text))
                {
                    theseAnswers = mySQL.GetAnswers(thisQuestion.QuestionID);
                    SerializeAnswers(theseAnswers);
                    lbAnswers.DataSource     = theseAnswers;
                    lbAnswers.DataTextField  = "AnswerText";
                    lbAnswers.DataValueField = "AnswerID";
                    lbAnswers.DataBind();

                    /*
                     * ListItem li = new ListItem();
                     * li.Text = "New Answer";
                     * li.Value = new Guid("00000000-0000-0000-0000-000000000000").ToString();
                     * foreach (classes.Answer thisAnswer in theseAnswers)
                     * {
                     *  li = new ListItem();
                     *  li.Text = thisAnswer.AnswerText;
                     *  li.Value = thisAnswer.AnswerID.ToString();
                     *  ddlAnswers.Items.Add(li);
                     * }
                     * */
                }
            }
            txtAnswerText.Text = "";
            txtSortOrder.Text  = "";
        }
示例#2
0
 private void LoadQuestions(Guid SurveyID)
 {
     classes.SQLCode mySQL = new classes.SQLCode();
     theseQuestions = mySQL.GetQuestionsBySurvey(SurveyID);
     foreach (classes.Question thisQuestion in theseQuestions)
     {
         List <classes.Answer> qAnswers = mySQL.GetAnswers(thisQuestion.QuestionID);
         foreach (classes.Answer thisAnswer in qAnswers)
         {
             theseAnswers.Add(thisAnswer);
         }
     }
     SerializeQuestions(theseQuestions);
     SerializeAnswers(theseAnswers);
 }