Exemple #1
0
        private void BindAnswers()
        {
            AnswerBll abll = new AnswerBll();

            this.rpAnswers.DataSource = abll.GetModelOfQuestion(int.Parse(this.lblQuestionId.Text));
            this.rpAnswers.DataBind();
        }
        protected void rpList_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataRowView row       = e.Item.DataItem as DataRowView;
            Repeater    rpSubList = e.Item.FindControl("rpSubList") as Repeater;
            AnswerBll   abll      = new AnswerBll();

            rpSubList.DataSource = abll.GetModelOfQuestion(Convert.ToInt32(row["QuestionId"]));
            rpSubList.DataBind();
        }
Exemple #3
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;
            }
        }
Exemple #4
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();
        }