protected void Page_Load(object sender, EventArgs e)
    {
        DataBase.Exams DbExams = new DataBase.Exams();

        DbExams.RetrieveExams(Convert.ToInt32(Session["IncomingPaper"]));

        string path = String.Format("C://Cosmo//Teachers/QuestionPaper/Exams/Config/{0}", DbExams.ExamData);

        ConfigFile.Sections ConfigSections = new ConfigFile.Sections(path);

        Secs.Add(ConfigSections.SectionCount, ConfigSections.SectionWeight, QuestionPanel);

        DataBase.Questions Quests = new DataBase.Questions(DbExams.ExamCode);

        Quests.RetrieveData();

        foreach (DataRow Row in Quests.DataSet.Tables[0].Rows)
        {
            List <string> ls = new List <string>();

            if (Row["Objective Data"] != DBNull.Value)
            {
                ls = ((string[])Row["Objective Data"]).ToList();
            }

            else
            {
                ls = null;
            }


            AddQuestion(Convert.ToInt32(Row["Section"]), Convert.ToInt32(Row["Question Type"]), Convert.ToInt32(Row["Question Number"]), Row["Question"].ToString(), null, ls);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ExData = (Exams)Session["ExamData"];

        try
        {
            TestCode = ExData.ExamCode;

            // TestCode = "TST0041/005";

            MyBank.TestCodeData = this.TestCode;

            DbExams = new DataBase.Exams();

            DbExams.RetrieveExams(TestCode);

            PaperHeader.InnerText = DbExams.ExamName;

            string path = String.Format("C://Cosmo//Teachers/QuestionPaper/Exams/Config/{0}", DbExams.ExamData);

            System.Diagnostics.Debug.WriteLine("There is sec " + ExData.Sections);

            DropDownList SectionSelector = (DropDownList)MyBank.FindControl("SectionSelection");

            ConfigFile MyConfigurations = new ConfigFile(path, ExData.Sections);

            ConfigFile.Sections ConfigSections = new ConfigFile.Sections(path);

            Secs.Add(ConfigSections.SectionCount, ConfigSections.SectionWeight, QuestionPanel);

            DataBase.Questions Qs = new DataBase.Questions(TestCode);


            if (ConfigSections.SectionCount > 1)
            {
                SectionSelector.Visible = true;
            }
            else
            {
                SectionSelector.Visible = false;
            }

            /*Retrieve Question Paper Data from DataSet and Pass it into Table*/

            foreach (int Weight in ConfigSections.SectionWeight)
            {
                System.Diagnostics.Debug.WriteLine("The Ratio is: " + Weight.ToString());
            }

            Qs.RetrieveData();

            DataSet Ds = new DataSet();

            Ds = Qs.DataSet;

            /*Instance of Table Holding Question Data for The Exam Selected*/

            DataTable dt = new DataTable();

            dt = Ds.Tables[0];

            if (dt.Rows.Count > 0)
            {
                QuestionPanel.Style.Add(HtmlTextWriterStyle.BackgroundImage, "url(QuestionPaper/Images/CosmoPaperBackground.png)");
            }

            foreach (DataRow Dr in dt.Rows)
            {
                List <string> ls = new List <string>();

                if (Dr[3] != DBNull.Value)
                {
                    ls = ((string[])Dr[3]).ToList();
                }

                else
                {
                    ls = null;
                }


                AddQuestion(Convert.ToInt32(Dr[4]), Convert.ToInt32(Dr[2]), Convert.ToInt32(Dr[0]), Dr[1].ToString(), ls, null);
            }
        }
        catch
        {
            Response.Redirect("Tests.aspx");
        }
    }