private void Fill()
    {
        int GallerySubjet_ID = int.Parse(Request.QueryString["ID_GallerySubject"]);
        DataTable dt = new tbl_GallerySubjectTableAdapter().GetDataByGallerySubjet_ID(GallerySubjet_ID);
        TitleContent = dt.Rows[0]["gs_title"].ToString();
        DateContent = dt.Rows[0]["gs_Date"].ToString();
        BazdidContent = dt.Rows[0]["gs_Bazdid"].ToString();

        // موضوع

        Label2.Text = "موضوع : <b>گالری تصاویر</b>";

        // نویسنده مطلب
        DataTable dt2;
        string Con_ID_Role = "0";

        dt2 = new tbl_AdminInformationTableAdapter().GetDataByID(int.Parse(dt.Rows[0]["gs_ID_Admin"].ToString()));
        AuthorContent = dt2.Rows[0]["AI_Name"].ToString();
        if (AuthorContent.Trim().Length == 0)
        {
            AuthorContent = dt2.Rows[0]["AI_UserName"].ToString();

        }
        Con_ID_Role = dt2.Rows[0]["Admin_ID"].ToString();

        AuthorContent = "<a href='./index.aspx?Type=AdminDetail&" +
                "ID_Admin=" + Con_ID_Role + "'>" +
                AuthorContent + "</a>";

        DataTable dt3 = new tbl_GalleryPictureTableAdapter().GetDataBygp_ID_GallerySubject(GallerySubjet_ID);
        DataList1.DataSource = dt3;
        DataList1.DataBind();

        // مسیر قرارگیری مطلب
        FillPath(dt.Rows[0]["gs_id_category"].ToString());
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int ID = int.Parse(((Label)(GridView1.Rows[e.RowIndex].FindControl("lblID"))).Text);
        int i = 0;

        // Delete Teacher
        DataTable dt20 = new tbl_TeacherInformationTableAdapter().GetDataByAdmin(ID);
        for (int h = 0; h < dt20.Rows.Count; h++)
        {
            new tbl_LinkTableAdapter().DeletePerson(int.Parse(dt20.Rows[i]["Teacher_ID"].ToString()),"Teacher");
            new tbl_ContentTableAdapter().DeletePerson("Teacher",int.Parse(dt20.Rows[i]["Teacher_ID"].ToString()));
            new tbl_PersonalMessageTableAdapter().DeleteUserMessage("Teacher", int.Parse(dt20.Rows[i]["Teacher_ID"].ToString()));

            // Delete Lesson
            DataTable dt3 = new tbl_LessonTableAdapter().GetDataByAllTeacher(int.Parse(dt20.Rows[i]["Teacher_ID"].ToString()));
            for (i = 0; i < dt3.Rows.Count; i++)
            {
                DataTable dt4 = new tbl_ScoreTitleTableAdapter().GetDataByID_Lesson(int.Parse(dt3.Rows[i]["Lesson_ID"].ToString()));
                for (int j = 0; j < dt4.Rows.Count; j++)
                {
                    new tbl_ScoreTableAdapter().DeleteTitle(int.Parse(dt4.Rows[j]["ScoreTitle_ID"].ToString()));
                }
                new tbl_ScoreTitleTableAdapter().DeleteLesson(int.Parse(dt3.Rows[i]["Lesson_ID"].ToString()));

                // Delete Test
                DataTable dt6 = new tbl_TestTableAdapter().GetDataByt_id_lesson(int.Parse(dt3.Rows[i]["Lesson_ID"].ToString()));
                for (int k = 0; k < dt4.Rows.Count; k++)
                {
                    DataTable dt7 = new tbl_TestQuestionTableAdapter().GetDataByDetailStudent(int.Parse(dt6.Rows[k]["ID_Test"].ToString()));
                    for (int f = 0; f < dt7.Rows.Count; f++)
                    {
                        new tbl_TestResultDetailTableAdapter().DeleteQuestion(int.Parse(dt7.Rows[f]["TestQuestion_ID"].ToString()));
                    }
                    new tbl_TestQuestionTableAdapter().DeleteTest(int.Parse(dt6.Rows[k]["ID_Test"].ToString()));

                    new tbl_TestResultTableAdapter().DeleteTest(int.Parse(dt6.Rows[k]["ID_Test"].ToString()));
                }
                new tbl_TestTableAdapter().DeleteLesson(int.Parse(dt3.Rows[i]["Lesson_ID"].ToString()));
            }
            new tbl_LessonTableAdapter().DeleteTeacher(int.Parse(dt20.Rows[i]["Teacher_ID"].ToString()));

        }
        new tbl_TeacherInformationTableAdapter().DeleteAdmin(ID);

        // Delete Student Parent
        DataTable dt = new tbl_StudentInformationTableAdapter().GetDataByAdmin(ID);
        for (i = 0; i < dt.Rows.Count; i++)
        {
            new tbl_PersonalMessageTableAdapter().DeleteUserMessage("Student",
                int.Parse(dt.Rows[i]["Student_ID"].ToString()));
            new tbl_ScoreTableAdapter().DeleteStudent(int.Parse(dt.Rows[i]["Student_ID"].ToString()));

            DataTable dt10 = new tbl_ParentInformationTableAdapter().GetDataByPA_ID_Student(int.Parse(dt.Rows[i]["Student_ID"].ToString()));
            for (int f = 0; f < dt10.Rows.Count; f++)
            {
                new tbl_PersonalMessageTableAdapter().DeleteUserMessage("Parent",
                    int.Parse(dt10.Rows[f]["Parent_ID"].ToString()));
            }
            new tbl_ParentInformationTableAdapter().DeleteStudent(int.Parse(dt.Rows[i]["Student_ID"].ToString()));
        }
        new tbl_StudentInformationTableAdapter().DeleteAdmin(ID);

        // Delete Gallery
        DataTable dt5 = new tbl_GallerySubjectTableAdapter().GetDataByAdmin(ID);
        for (i = 0; i < dt5.Rows.Count; i++)
        {
            new tbl_GalleryPictureTableAdapter().Deletegp_ID_GallerySubject(int.Parse(dt5.Rows[i]["GallerySubjet_ID"].ToString()));
        }
        new tbl_GallerySubjectTableAdapter().DeleteAdmin(ID);

        new tbl_AdminSecurityTableAdapter().DeleteAS_ID_Admin(ID);
        new tbl_AdminPermissionCategoryTableAdapter().DeleteAPC_ID_Admin(ID);
         new tbl_ContentTableAdapter().DeletePerson("Admin", ID);
           new tbl_LinkTableAdapter().DeletePerson(ID, "Admin");
        new tbl_PersonalMessageTableAdapter().DeleteUserMessage("Admin", ID);
        new tbl_AdminInformationTableAdapter().DeleteAdmin(ID);
        FillGrid();
        Cancel();
    }
    private void Fill()
    {
        int ID = int.Parse(Request.QueryString["ID_GallerySubject"].ToString());
        DataTable dt = new tbl_GallerySubjectTableAdapter().GetDataByGallerySubjet_ID(ID);
        if (dt.Rows.Count > 0)
        {
            LblHidden.ToolTip = Request.QueryString["ID_GallerySubject"].ToString();
            TextName.Text = dt.Rows[0]["gs_title"].ToString();
            CheckBox1.Checked=bool.Parse( dt.Rows[0]["gs_Active"].ToString());

        }
        FillFileUpload();
        DataTable dt2 = new tbl_CategoryTableAdapter().GetDataByID(int.Parse(dt.Rows[0]["gs_ID_Category"].ToString()));
        if (dt2.Rows.Count > 0)
        {
            string delimitedInfo = dt2.Rows[0]["Cat_Path"].ToString();
            string[] discreteInfo = delimitedInfo.Split(new char[] { ',' });
            int i = 1;
            foreach (string Data in discreteInfo)
            {
                if (Data == "-1")
                {
                    FillDr(int.Parse(Data), (DropDownList)FindControl("DropDownList" + i.ToString()));
                }
                else
                {
                    ((DropDownList)(FindControl("DropDownList" + (i - 1).ToString()))).Items.FindByValue(Data).Selected = true;
                    FillDr(int.Parse(Data), (DropDownList)FindControl("DropDownList" + i.ToString()));
                }
                i++;
            }
            ((DropDownList)(FindControl("DropDownList" + (i - 1).ToString()))).Items.FindByValue(dt.Rows[0]["gs_ID_Category"].ToString()).Selected = true;

        }
        Panel1.Visible = true;
        FillPath();
    }