Example #1
0
        protected void rpAnswers_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            AnswerBll abll     = new AnswerBll();
            int       answerId = Convert.ToInt32(e.CommandArgument);

            if (e.CommandName == "del")
            {
                abll.Delete(answerId);
                BindAnswers();
            }
            else if (e.CommandName == "edit")
            {
                AnswerModel amodel = abll.GetModel(answerId);
                this.lblAnswerId.Text = amodel.AnswerId.ToString();
                this.txtAContent.Text = amodel.Content;
                this.txtATitle.Text   = amodel.Title;
            }
        }
Example #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            AnswerBll   abll   = new AnswerBll();
            AnswerModel amodel = null;

            if (this.lblAnswerId.Text == "")
            {
                amodel            = new AnswerModel();
                amodel.QuestionId = int.Parse(this.lblQuestionId.Text);
            }
            else
            {
                amodel = abll.GetModel(int.Parse(this.lblAnswerId.Text));
            }
            amodel.Content   = this.txtAContent.Text.Trim();
            amodel.Title     = this.txtATitle.Text.Trim();
            txtAContent.Text = "";
            txtATitle.Text   = "";

            abll.Save(amodel);
            BindAnswers();
        }