private void BindGridData(int index)
    {
        if (Session["Topic1"] != null)
        {
            DataSet dsResult = new DataSet();
            Student_DashBoard_BLogic Student_BAL = new Student_DashBoard_BLogic();
            int SubjectID = Convert.ToInt32(Session["SubjectID"].ToString());
            int ChapterID = Convert.ToInt32(Session["ChapterID"].ToString());
            int TopicID   = Convert.ToInt32(Session["TopicID1"].ToString());

            int    BMSID     = Convert.ToInt32(Session["BMSID"].ToString());
            int    StudentID = Convert.ToInt32(Session["StudentID"].ToString());
            string TestType  = string.Empty;

            if (index == 0)
            {
                TestType = "Pretest";
            }
            else if (index == 1)
            {
                TestType = "Posttest";
            }

            dsResult = Student_BAL.BAL_SelectStudentTestResultwithDetails(SubjectID, ChapterID, TopicID, BMSID, StudentID, TestType);
            if (dsResult.Tables[0].Rows.Count > 0)
            {
                tblTestResult.Visible = true;
                trError.Visible       = false;
                gvAnalysis.DataSource = dsResult;
                gvAnalysis.DataBind();
                int Right = 0;
                int Wrong = 0;
                int count = dsResult.Tables[0].Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "True")
                    {
                        Right++;
                    }
                    else if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "False")
                    {
                        Wrong++;
                    }
                }
                double per = Convert.ToDouble((100 * Right) / count);
                lblAverageValue.Text = per.ToString() + " %";
            }
            else
            {
                gvAnalysis.DataSource = null;
                gvAnalysis.DataBind();
                trError.Visible       = true;
                tblTestResult.Visible = false;
            }
        }
    }
    private void BindGridData()
    {
        try
        {
            DataSet dsResult = new DataSet();
            Student_DashBoard_BLogic Student_BAL = new Student_DashBoard_BLogic();
            int SubjectID = Convert.ToInt32(Session["SubjectID"].ToString());
            int ChapterID = Convert.ToInt32(Session["ChapterID"].ToString());
            int TopicID   = Convert.ToInt32(Session["TopicID1"].ToString());

            int    BMSID     = Convert.ToInt32(Session["BMSID"].ToString());
            int    StudentID = Convert.ToInt32(Session["StudentID"].ToString());
            string TestType  = string.Empty;

            dsResult = Student_BAL.BAL_SelectStudentTestResultwithDetails(SubjectID, ChapterID, TopicID, BMSID, StudentID, TestType);
            if (dsResult.Tables[0].Rows.Count > 0)
            {
                int Right = 0;
                int Wrong = 0;
                int count = dsResult.Tables[0].Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "True")
                    {
                        Right++;
                    }
                    else if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "False")
                    {
                        Wrong++;
                    }
                }
                double per = Convert.ToDouble((100 * Right) / count);
            }
            else
            {
            }
        }
        catch (Exception)
        {
            grchapterwiseperformance.DataSource = null;
            grchapterwiseperformance.DataBind();
        }
    }
    private void BindGridData1(DataTable dt)
    {
        try
        {
            DataSet dsResult = new DataSet();
            double  per      = 0.0;

            if (dt.Rows.Count > 0)
            {
                int count = 1;
                for (int k = 0; k < dt.Rows.Count; k++)
                {
                    int ChapterID = Convert.ToInt32(dt.Rows[k]["ChapterID"]);
                    int TopicID   = Convert.ToInt32(dt.Rows[k]["TopicID"]);

                    Student_DashBoard_BLogic Student_BAL = new Student_DashBoard_BLogic();
                    int SubjectID = Convert.ToInt32(ddlsubject.SelectedValue);


                    int    BMSID     = Convert.ToInt32(Session["BMSID"].ToString());
                    int    StudentID = Convert.ToInt32(Session["StudentID"].ToString());
                    string TestType  = string.Empty;

                    TestType = "Posttest";

                    dsResult = Student_BAL.BAL_SelectStudentTestResultwithDetails(SubjectID, ChapterID, TopicID, BMSID, StudentID, TestType);

                    if (dsResult.Tables[0].Rows.Count > 0)
                    {
                        count += dsResult.Tables[0].Rows.Count;
                        for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++)
                        {
                            if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "True")
                            {
                                Right++;
                            }
                            else if (dsResult.Tables[0].Rows[i]["Result"].ToString() == "False")
                            {
                                Wrong++;
                            }
                        }
                    }
                    per = Convert.ToDouble((100 * Right) / (count - 1));
                }
                if (Right == 0 && Wrong == 0)
                {
                }
                else
                {
                    DataRow dr;
                    dr               = dt1.NewRow();
                    dr["Chapter"]    = dt.Rows[0]["Chapter"].ToString();
                    dr["Persentage"] = per.ToString() + "%";
                    dt1.Rows.Add(dr);
                    grchapterwiseperformance.DataSource = dt1;
                    grchapterwiseperformance.DataBind();
                }

                if (dt1.Rows.Count == 0)
                {
                    grchapterwiseperformance.DataSource = dt1;
                    grchapterwiseperformance.DataBind();
                }
            }
        }
        catch (Exception)
        {
            grchapterwiseperformance.DataSource = null;
            grchapterwiseperformance.DataBind();
        }
    }