コード例 #1
0
        protected void EditAnswer_Command(object sender, CommandEventArgs e)
        {
            var context = new ConquistadorEntities();

            question = context.Questions.Find(questionId);

            if (answerId == 0)
            {
                isNewAnswer = true;
                answer = new Answer();
                answer.QuestionId = question.Id;
                context.Answers.Add(answer);
            }

            if (!isNewAnswer)
            {
                answer = context.Answers.Find(answerId);
            }

            try
            {
                answer.ContentText = this.TextBoxEdit.Text;
                context.SaveChanges();
                Response.Redirect("EditQuestions.aspx", false);
            }
            catch (Exception ex)
            {
                ErrorSuccessNotifier.AddErrorMessage(ex.Message);
                return;
            }
        }
コード例 #2
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            var context = new ConquistadorEntities();

            if (answerId == 0)
            {
                isNewAnswer = true;
            }

            if (!isNewAnswer)
            {
                answer = context.Answers.Find(answerId);
                this.TextBoxEdit.Text = answer.ContentText;
                this.DataBind();
            }

            else
            {
                this.TextBoxEdit.Text = "";
            }
        }