Example #1
0
        protected void rbAns_CheckedChanged(object sender, EventArgs e)
        {
            var chk  = (RadioButton)sender;
            var item = ((CheckBox)sender).Parent as RepeaterItem;
            var lbl  = (Label)item.FindControl("SQCID");


            var SQCID = int.Parse(lbl.Text);
            var a     = SQChoices.FetchObject(SQCID);

            foreach (RepeaterItem i in rptrRadio.Items)
            {
                var tmpSQCID = int.Parse(((Label)i.FindControl("SQCID")).Text);
                var rfv      = (RequiredFieldValidator)i.FindControl("rfvRBClarification");
                var txt      = (TextBox)i.FindControl("txtRBClarification");

                if (tmpSQCID != SQCID)
                {
                    rfv.Enabled = false;
                    txt.Text    = string.Empty;
                }
                else
                {
                    if (a.AskClarification && a.ClarificationRequired)
                    {
                        rfv.Enabled = true;
                    }
                }
            }

            if (DisplayDirection != "1")
            {
                RadioBoxScripts();
            }
        }
Example #2
0
        protected void btnAddAnswer4_Click(object sender, EventArgs e)
        {
            if (Session["tmpQ4"] == null)
            {
                Session["tmpQ4"] = SQChoices.GetAll(-1);
            }
            var tmpC4 = (int)Session["tmpC4"];

            tmpC4++;
            var     ds     = (DataSet)Session["tmpQ4"];
            DataRow newRow = ds.Tables[0].NewRow();

            newRow["ChoiceOrder"]    = tmpC4;
            newRow["ChoiceText"]     = ChoiceText4.Text;
            newRow["Score"]          = Score4.Text.SafeToInt();
            newRow["JumpToQuestion"] = JumpToQuestion4.Text.SafeToInt();
            ds.Tables[0].Rows.Add(newRow);

            Session["tmpQ4"] = ds;
            Session["tmpC4"] = tmpC4;

            rptrAnswers4.DataSource = ds;
            rptrAnswers4.DataBind();

            ChoiceText4.Text = "";
            Score4.Text      = "";
            JumpToQuestion4.SelectedValue = "0";
        }
Example #3
0
        protected void chkAns_CheckedChanged(object sender, EventArgs e)
        {
            var chk  = ((CheckBox)sender);
            var item = ((CheckBox)sender).Parent as RepeaterItem;
            var lbl  = (Label)item.FindControl("SQCID");
            var rfv  = (RequiredFieldValidator)item.FindControl("rfvChkClarification");
            var txt  = (TextBox)item.FindControl("txtChkClarification");

            var SQCID = int.Parse(lbl.Text);
            var a     = SQChoices.FetchObject(SQCID);

            if (!chk.Checked)
            {
                rfv.Enabled = false;
                txt.Text    = string.Empty;
            }
            else if (a.AskClarification && a.ClarificationRequired)
            {
                rfv.Enabled = true;
            }
            else
            {
                rfv.Enabled = false;
                txt.Text    = string.Empty;
            }

            CheckBoxScripts();
        }
Example #4
0
        public void RenderAnswers()
        {
            var ds = SQChoices.GetAll(int.Parse(QID));

            if (DisplayControl == "3") //drop down
            {
                ddMultipleChoice.Visible = true;
                ddMultipleChoice.Items.Clear();
                ddMultipleChoice.Items.Add(new ListItem("[ Make a selection ]", "0"));
                foreach (DataRow r  in ds.Tables[0].Rows)
                {
                    ddMultipleChoice.Items.Add(new ListItem(Convert.ToString(r["ChoiceText"]), r["SQCID"].ToString()));
                }
                rfvddMultipleChoice.Enabled = (IsRequired == "yes");
            }

            if (DisplayControl == "1") //check
            {
                rptrChk.DataSource = ds;
                rptrChk.DataBind();
                CheckBoxScripts();
            }//

            if (DisplayControl == "2") //radio
            {
                rptrRadio.DataSource = ds;
                rptrRadio.DataBind();
                if (DisplayDirection != "1")
                {
                    RadioBoxScripts();
                }
            }//
        }
Example #5
0
        protected void btnAddAnswer2_Click(object sender, EventArgs e)
        {
            if (Session["tmpQ2"] == null)
            {
                Session["tmpQ2"] = SQChoices.GetAll(-1);
            }
            var tmpC2 = (int)Session["tmpC2"];

            tmpC2++;
            var     ds     = (DataSet)Session["tmpQ2"];
            DataRow newRow = ds.Tables[0].NewRow();

            newRow["ChoiceOrder"]           = tmpC2;
            newRow["ChoiceText"]            = ChoiceText2.Text;
            newRow["Score"]                 = Score2.Text.SafeToInt();
            newRow["JumpToQuestion"]        = JumpToQuestion2.Text.SafeToInt();
            newRow["AskClarification"]      = AskClarification2.Checked;
            newRow["ClarificationRequired"] = ClarificationRequired2.Checked;
            ds.Tables[0].Rows.Add(newRow);

            Session["tmpQ2"] = ds;
            Session["tmpC2"] = tmpC2;

            rptrAnswers2.DataSource = ds;
            rptrAnswers2.DataBind();

            ChoiceText2.Text = "";
            Score2.Text      = "";
            JumpToQuestion2.SelectedValue  = "0";
            AskClarification2.Checked      = false;
            ClarificationRequired2.Checked = false;
        }
Example #6
0
        protected void ddMultipleChoice_SelectedIndexChanged(object sender, EventArgs e)
        {
            var SQCID = int.Parse(ddMultipleChoice.SelectedValue);

            if (SQCID == 0)
            {
                txtDDClarification.Visible = false;
                rfvDDClarification.Enabled = false;
            }
            else
            {
                var a = SQChoices.FetchObject(SQCID);
                txtDDClarification.Visible = a.AskClarification;
                rfvDDClarification.Enabled = a.AskClarification && a.ClarificationRequired;
            }
        }
Example #7
0
        protected void btnClone_Click(object sender, ImageClickEventArgs e)
        {
            var so = Survey.FetchObject(int.Parse(SID.Text));
            var sn = Survey.FetchObject(int.Parse(SID.Text));

            sn.SID    = 0;
            sn.Name   = txtNewName.Text;
            sn.Status = 1;
            sn.Insert();

            var ds1 = SurveyQuestion.GetAll(so.SID);

            foreach (DataRow r1 in ds1.Tables[0].Rows)
            {
                var QID = Convert.ToInt32(r1["QID"]);

                var q = SurveyQuestion.FetchObject(QID);
                q.SID = sn.SID;
                q.QID = 0;
                q.Insert();

                var ds2 = SQChoices.GetAll(QID);
                foreach (DataRow r2 in ds2.Tables[0].Rows)
                {
                    var SQCID = Convert.ToInt32(r2["SQCID"]);
                    var c     = SQChoices.FetchObject(SQCID);
                    c.SQCID = 0;
                    c.QID   = q.QID;
                    c.Insert();
                }

                var ds3 = SQMatrixLines.GetAll(QID);
                foreach (DataRow r3 in ds3.Tables[0].Rows)
                {
                    var SQMLID = Convert.ToInt32(r3["SQMLID"]);
                    var l      = SQMatrixLines.FetchObject(SQMLID);
                    l.SQMLID = 0;
                    l.QID    = q.QID;
                    l.Insert();
                }
            }
            Session["SID"] = sn.SID;
            Response.Redirect("SurveyList.aspx");
            Response.Redirect("SurveyAddEdit.aspx");
        }
Example #8
0
        protected void SaveType4Answers(int QID)
        {
            if (Session["tmpQ4"] == null)
            {
                return;
            }
            var ds = (DataSet)Session["tmpQ4"];

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                var obj = new SQChoices();
                obj.QID            = QID;
                obj.ChoiceText     = r["ChoiceText"].ToString();
                obj.Score          = (int)r["Score"];
                obj.JumpToQuestion = (int)r["JumpToQuestion"];

                obj.Insert();
            }
        }
Example #9
0
        public int JumpLogicActivated()
        {
            int qtype = 0;

            int.TryParse(lblQType.Text, out qtype);

            switch (qtype)
            {
            case 1:
                return(-1);

            case 3:
                return(-1);

            case 2:
                var ds1 = SQChoices.GetAll(int.Parse(QID));
                if (DisplayControl == "1")
                {
                    foreach (RepeaterItem rChkI in rptrChk.Items)
                    {
                        var SQCID  = rChkI.FindControl("SQCID") as Label;
                        var chkAns = rChkI.FindControl("chkAns") as CheckBox;
                        if (chkAns.Checked)
                        {
                            foreach (DataRow dr1 in ds1.Tables[0].Rows)
                            {
                                if (Convert.ToString(dr1["SQCID"]) == SQCID.Text && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                                {
                                    return(Convert.ToInt32(dr1["JumpToQuestion"]));
                                }
                            }
                        }
                    }
                }
                if (DisplayControl == "2")
                {
                    foreach (RepeaterItem rRdoI in rptrRadio.Items)
                    {
                        var SQCID = rRdoI.FindControl("SQCID") as Label;
                        var rbAns = rRdoI.FindControl("rbAns") as RadioButton;
                        if (rbAns.Checked)
                        {
                            foreach (DataRow dr1 in ds1.Tables[0].Rows)
                            {
                                if (Convert.ToString(dr1["SQCID"]) == SQCID.Text && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                                {
                                    return(Convert.ToInt32(dr1["JumpToQuestion"]));
                                }
                            }
                        }
                    }
                }
                if (DisplayControl == "3")
                {
                    var SQCID = ddMultipleChoice.SelectedValue;
                    foreach (DataRow dr1 in ds1.Tables[0].Rows)
                    {
                        if (Convert.ToString(dr1["SQCID"]) == SQCID && Convert.ToInt32(dr1["JumpToQuestion"]) > 0)
                        {
                            return(Convert.ToInt32(dr1["JumpToQuestion"]));
                        }
                    }
                }
                return(-1);

            case 4:
                var ds2 = SQChoices.GetAll(int.Parse(QID));
                foreach (RepeaterItem rLine in rptrMRows.Items)
                {
                    if (DisplayControl == "1")
                    {
                        var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater;
                        foreach (RepeaterItem rChkI in rptrCheckCols.Items)
                        {
                            var chkAns      = rChkI.FindControl("rbChoice") as CheckBox;
                            var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label;
                            var JumpQ       = Convert.ToInt32(ds2.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["JumpToQuestion"]);
                            if (chkAns.Checked && JumpQ > 0)
                            {
                                return(JumpQ);
                            }
                        }
                    }
                    if (DisplayControl == "2")
                    {
                        var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater;
                        foreach (RepeaterItem rRdoI in rptrRadioCols.Items)
                        {
                            var rbAns       = rRdoI.FindControl("rbChoice") as RadioButton;
                            var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label;
                            var JumpQ       = Convert.ToInt32(ds2.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["JumpToQuestion"]);
                            if (rbAns.Checked && JumpQ > 0)
                            {
                                return(JumpQ);
                            }
                        }
                    }
                }
                return(-1);

            case 5:
                return(-1);

            case 6:
                return(-1);
            }
            return(-1);
        }
Example #10
0
        public void SaveMatrix()
        {
            int SRPK = int.Parse(SRID);
            var ds   = SQChoices.GetAll(int.Parse(QID));

            foreach (RepeaterItem rLine in rptrMRows.Items)
            {
                var obj1 = SurveyResults.FetchObject(SRPK);
                var obj2 = new SurveyAnswers();

                obj2.SRID  = obj1.SRID;
                obj2.TenID = obj1.TenID;
                obj2.PID   = obj1.PID;
                obj2.SID   = obj1.SID;

                obj2.QID          = int.Parse(QID);
                obj2.DateAnswered = DateTime.Now;
                obj2.QType        = 4;

                var SQMLID = rLine.FindControl("SQMLID") as Label;
                obj2.SQMLID = int.Parse(SQMLID.Text);

                if (DisplayControl == "1")
                {
                    var rptrCheckCols = rLine.FindControl("rptrCheckCols") as Repeater;
                    foreach (RepeaterItem rChkI in rptrCheckCols.Items)
                    {
                        var SQCID       = rChkI.FindControl("SQCID") as Label;
                        var chkAns      = rChkI.FindControl("rbChoice") as CheckBox;
                        var ChoiceOrder = rChkI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();
                        if (chkAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);


                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }
                if (DisplayControl == "2")
                {
                    var rptrRadioCols = rLine.FindControl("rptrRadioCols") as Repeater;
                    foreach (RepeaterItem rRdoI in rptrRadioCols.Items)
                    {
                        var SQCID       = rRdoI.FindControl("SQCID") as Label;
                        var rbAns       = rRdoI.FindControl("rbChoice") as RadioButton;
                        var ChoiceOrder = rRdoI.FindControl("ChoiceOrder") as Label;
                        var AnsText     = ds.Tables[0].Rows[int.Parse(ChoiceOrder.Text) - 1]["ChoiceText"].ToString();


                        if (rbAns.Checked)
                        {
                            obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                                 (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                            obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                                  (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), AnsText);
                        }
                    }
                }

                obj2.Insert();
            }
        }
Example #11
0
        public void SaveMultiChoice()
        {
            int SRPK = int.Parse(SRID);
            var obj1 = SurveyResults.FetchObject(SRPK);
            var obj2 = new SurveyAnswers();

            obj2.SRID  = obj1.SRID;
            obj2.TenID = obj1.TenID;
            obj2.PID   = obj1.PID;
            obj2.SID   = obj1.SID;

            obj2.QID          = int.Parse(QID);
            obj2.DateAnswered = DateTime.Now;
            obj2.QType        = 2;

            if (DisplayControl == "1")
            {
                foreach (RepeaterItem rChkI in rptrChk.Items)
                {
                    var SQCID   = rChkI.FindControl("SQCID") as Label;
                    var chkAns  = rChkI.FindControl("chkAns") as CheckBox;
                    var chkClar = rChkI.FindControl("txtChkClarification") as TextBox;

                    if (chkAns.Checked)
                    {
                        obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                        obj2.ClarificationText = string.Format("{0}{1}{2}",
                                                               (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""),
                                                               (obj2.ClarificationText.Length > 0 ? "~|~" : ""), chkClar.Text);
                        obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                              (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                              (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), chkAns.Text);
                    }
                }
            }
            if (DisplayControl == "2")
            {
                foreach (RepeaterItem rRdoI in rptrRadio.Items)
                {
                    var SQCID  = rRdoI.FindControl("SQCID") as Label;
                    var rbAns  = rRdoI.FindControl("rbAns") as RadioButton;
                    var rbClar = rRdoI.FindControl("txtRBClarification") as TextBox;

                    if (rbAns.Checked)
                    {
                        obj2.ChoiceAnswerIDs = string.Format("{0}{1}{2}",
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? obj2.ChoiceAnswerIDs : ""),
                                                             (obj2.ChoiceAnswerIDs.Length > 0 ? "," : ""), SQCID.Text);
                        obj2.ClarificationText = string.Format("{0}{1}{2}",
                                                               (obj2.ClarificationText.Length > 0 ? obj2.ClarificationText : ""),
                                                               (obj2.ClarificationText.Length > 0 ? "~|~" : ""), rbClar.Text);
                        obj2.ChoiceAnswerText = string.Format("{0}{1}{2}",
                                                              (obj2.ChoiceAnswerText.Length > 0 ? obj2.ChoiceAnswerText : ""),
                                                              (obj2.ChoiceAnswerText.Length > 0 ? "~|~" : ""), rbAns.Text);
                    }
                }
            }
            if (DisplayControl == "3")
            {
                obj2.ChoiceAnswerIDs = ddMultipleChoice.SelectedValue;
                var ch  = SQChoices.FetchObject(int.Parse(ddMultipleChoice.SelectedValue));
                var ans = "N/A";
                if (ch != null)
                {
                    ans = ch.ChoiceText;
                }
                obj2.ChoiceAnswerText  = ans;
                obj2.ClarificationText = txtDDClarification.Text;
            }

            obj2.Insert();
        }
        public string DisplayAnswers(int QType, int QID, int SQMLID, string ChoiceAnswerIDs, string ChoiceAnswerText, string ClarificationText, bool MXShowChoices)
        {
            var displayString = string.Empty;

            if (QType == 2) // Multiple Choice
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);

                var ds4 = SQChoices.GetAll(QID);
                foreach (DataRow dr4 in ds4.Tables[0].Rows)
                {
                    var idx4      = -1;
                    var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                    var ansString = string.Format("<tr><td valign='top'><b>{2}</b></td><td valign='top' nowrap>{0}</td><td nowrap style='padding-right: 5px;' align='right' valign='top'>({1} pts)</td><td style='padding-left:10px;' valign='top'>{3}</td></tr>"
                                                  , dr4["ChoiceText"].ToString(), ((int)dr4["Score"])
                                                  , match ? " X " : ""
                                                  , match ? mcCLs[idx4] : ""

                                                  );
                    displayString = string.Format("{0}{1}", displayString, ansString);
                }

                displayString = string.Format("<table cellpadding=5> {0} </table>", displayString);
            }

            if (QType == 4) // Matrix
            {
                string[] separators = { "~|~" };
                var      mcIDs      = ChoiceAnswerIDs.Split(',');
                var      mcTXs      = ChoiceAnswerIDs.Split(separators, StringSplitOptions.None);
                var      mcCLs      = ClarificationText.Split(separators, StringSplitOptions.None);


                var ds4 = SQChoices.GetAll(QID);
                var ml  = SQMatrixLines.FetchObject(SQMLID);

                displayString = string.Format("<tr><td valign='top' style='padding-right: 5px;' width='50%'>{0}</td>", ml.LineText);
                var w = (int)(50 / ds4.Tables[0].Rows.Count);

                if (MXShowChoices)
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{4}%' >{0} ({1} pts) <br> <b>{2}</b> <br> <div style='text-align: left;'>{3}</div></td>"
                                                      , dr4["ChoiceText"].ToString()
                                                      , ((int)dr4["Score"])
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }
                else
                {
                    foreach (DataRow dr4 in ds4.Tables[0].Rows)
                    {
                        var idx4      = -1;
                        var match     = FindAnswer(ChoiceAnswerIDs, mcIDs, (int)dr4["SQCID"], out idx4);
                        var ansString = string.Format("<td valign='top' align='center' width='{2}%' ><b>{0}</b> <br> <div style='text-align: left;'>{1}</div></td>"
                                                      , match ? " X " : ""
                                                      , match ? mcCLs[idx4] : ""
                                                      , w
                                                      );
                        displayString = string.Format("{0}{1}", displayString, ansString);
                    }
                }

                displayString = string.Format("<table cellpadding=5 width='100%'> {0} </tr></table>", displayString);
            }

            return(displayString);
        }
        protected void DvItemCommand(object sender, DetailsViewCommandEventArgs e)
        {
            string returnURL = "~/ControlRoom/Modules/Setup/SurveyQuestionList.aspx";

            if (e.CommandName.ToLower() == "back")
            {
                Response.Redirect(returnURL);
            }
            if (e.CommandName.ToLower() == "refresh")
            {
                try
                {
                    odsData.DataBind();
                    dv.DataBind();
                    dv.ChangeMode(DetailsViewMode.Edit);

                    var masterPage = (IControlRoomMaster)Master;
                    if (masterPage != null)
                    {
                        masterPage.PageMessage = SRPResources.RefreshOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }
            if (e.CommandName.ToLower() == "save" || e.CommandName.ToLower() == "saveandback")
            {
                try
                {
                    if (Save((DetailsView)sender))
                    {
                        if (e.CommandName.ToLower() == "saveandback")
                        {
                            Response.Redirect(returnURL);
                        }

                        odsData.DataBind();
                        dv.DataBind();
                        dv.ChangeMode(DetailsViewMode.Edit);

                        MasterPage.PageMessage = SRPResources.SaveOK;
                    }
                }
                catch (Exception ex)
                {
                    var masterPage = (IControlRoomMaster)Master;
                    masterPage.PageError = String.Format(SRPResources.ApplicationError1, ex.Message);
                }
            }

            if (e.CommandName.ToLower() == "moveup21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord21")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType2Answers");
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord21")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType2Answers");

                var obj = new SQChoices();
                obj.QID                   = int.Parse(lblPK.Text);
                obj.ChoiceText            = ((TextBox)p4.FindControl("ChoiceText2")).Text;
                obj.Score                 = ((TextBox)p4.FindControl("Score2")).Text.SafeToInt();
                obj.JumpToQuestion        = ((DropDownList)p4.FindControl("JumpToQuestion2")).Text.SafeToInt();
                obj.AskClarification      = ((CheckBox)p4.FindControl("AskClarification2")).Checked;
                obj.ClarificationRequired = ((CheckBox)p4.FindControl("ClarificationRequired2")).Checked;
                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel1");
                var gv = (GridView)p4.FindControl("gv21");
                gv.DataBind();
            }


            if (e.CommandName.ToLower() == "moveup41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";

                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movedn41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQChoices.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "deleterecord41")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQChoices.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData41.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecord41")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                var p4   = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQChoices();
                obj.QID            = int.Parse(lblPK.Text);
                obj.ChoiceText     = ((TextBox)p4.FindControl("ChoiceText4")).Text;
                obj.Score          = ((TextBox)p4.FindControl("Score4")).Text.SafeToInt();
                obj.JumpToQuestion = ((DropDownList)p4.FindControl("JumpToQuestion4")).Text.SafeToInt();

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                odsData41.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv41");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "moveupl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveUp(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Up!";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "movednl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                SQMatrixLines.MoveDn(key);
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }



            if (e.CommandName.ToLower() == "deleterecordl")
            {
                var key = Convert.ToInt32(e.CommandArgument);
                var obj = SQMatrixLines.FetchObject(key);
                obj.Delete();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");
                odsData42.DataBind();
                var p4 = (Panel)tab2.FindControl("pnlType4Answers");
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }

            if (e.CommandName.ToLower() == "addrecordl")
            {
                var tab2 = ((DetailsView)sender).FindControl("TabContainer1").FindControl("TabPanel2");

                var p4 = (Panel)tab2.FindControl("pnlType4Answers");

                var obj = new SQMatrixLines();
                obj.QID      = int.Parse(lblPK.Text);
                obj.LineText = ((TextBox)p4.FindControl("LineText4")).Text;

                obj.Insert();
                //MasterPage.PageMessage = "Survey/Test Question Moved Down";

                odsData42.DataBind();
                p4 = (Panel)p4.FindControl("Panel2");
                var gv = (GridView)p4.FindControl("gv42");
                gv.DataBind();
            }
        }