Ejemplo n.º 1
0
 protected void DeleteClick(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(MetaQuestionId))
     {
         MetadataSurveyQuestion question = new MetadataSurveyQuestion();
         question.Delete(int.Parse(MetaQuestionId));
     }
     ReloadMainPage(MetaSurveyId);
 }
Ejemplo n.º 2
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            base.Page_Load(sender, e);
            if (!Page.IsPostBack)
            {
                int?surveyId   = null;
                int?questionId = null;
                if (!string.IsNullOrEmpty(MetaSurveyId))
                {
                    surveyId = int.Parse(MetaSurveyId);
                }
                if (!string.IsNullOrEmpty(MetaQuestionId))
                {
                    questionId = int.Parse(MetaQuestionId);
                }
                if (QueryAction == "load")
                {
                    if (surveyId.HasValue)
                    {
                        IEnumerable <MetadataSurveyQuestion> questions = new MetadataSurveyQuestion[0];
                        // load single question
                        if (questionId.HasValue)
                        {
                            MetadataSurveyQuestion question = new MetadataSurveyQuestion();
                            question.Get(questionId.Value);
                            questions = new MetadataSurveyQuestion[] { question };
                        }
                        // load all questions
                        else
                        {
                            questions = BusinessObject.GetByParent <MetadataSurveyQuestion>(surveyId.Value);
                        }

                        // data bind
                        DataView questionsView = questions.AsDataView <MetadataSurveyQuestion>();
                        questionsView.Table.Columns.Add(new DataColumn("ColSortOrder", typeof(Int32), "ISNULL(SortNumber," + int.MaxValue + ")"));
                        questionsView.Sort = "ColSortOrder ASC";

                        ReadOnlyRptr.DataSource = questionsView;
                        ReadOnlyRptr.DataBind();
                    }
                }
                else if (QueryAction == "delete")
                {
                    if (questionId.HasValue)
                    {
                        MetadataSurveyQuestion question = new MetadataSurveyQuestion();
                        question.Delete(questionId.Value);
                    }
                }
                PopulateForm(questionId);
            }
        }