private void Fill()
    {
        int ID = int.Parse(Request.QueryString["ID_Admin"]);
        DataTable dt = new tbl_AdminPermissionCategoryTableAdapter().GetDataByAPC_ID_Admin(ID);
        if (dt.Rows.Count > 0)
        {
            string delimitedInfo = dt.Rows[0]["APC_Cat_Patch"].ToString();
            string[] discreteInfo = delimitedInfo.Split(new char[] { ',' });
            int i = 1;
            foreach (string Data in discreteInfo)
            {
                if (Data != "-1")
                {
                    ((DropDownList)(FindControl("DropDownList" + i.ToString()))).SelectedIndex = -1;
                    ((DropDownList)(FindControl("DropDownList" + i.ToString()))).Items.FindByValue(Data).Selected = true;
                    if (i <= 5)
                    {
                        FillDr(int.Parse(Data), (DropDownList)FindControl("DropDownList" + (i + 1).ToString()));
                    }
                }
                i++;
            }
            Label1.Visible = true;
            Label1.Text = "برای این مدیر دسترسی زیر تعریف شده است :";
            LinkButton1.Text = "لغو دسترسی";
            PanelDrop.Enabled = true;
        }
        else
        {
            Label1.Text = "برای این مدیر دسترسی ای تعریف نشده است";
            LinkButton1.Text = "ایجاد دسترسی جدید";
            Label1.Visible = true;
            PanelDrop.Enabled = false;

        }
        Label2.Visible = false;
    }
    private void FillDr(int ID_Category, DropDownList Dr)
    {
        int ID = int.Parse(Request.Cookies["ID_Role"].Value);
        DataTable dt = new tbl_AdminPermissionCategoryTableAdapter().GetDataByAPC_ID_Admin(ID);
        string DR_ID = Dr.ID.Substring(Dr.ID.Length - 1, 1);
        if (dt.Rows.Count > 0)
        {
            string APC_Cat_Patch = dt.Rows[0]["APC_Cat_Patch"].ToString();
            string[] discreteInfo = APC_Cat_Patch.Split(new char[] { ',' });
            int i = 0;
            foreach (string Data in discreteInfo)
            {
                i++;
            }
            Dr.Items.Clear();
            Dr.DataValueField = "Category_ID";
            Dr.DataTextField = "Cat_Title";

            if (i >= int.Parse(DR_ID) && APC_Cat_Patch.Trim() != "-1")
            {
                Dr.DataSource = new tbl_CategoryTableAdapter().GetDataByIDRootPermissionAdmin(ID_Category, APC_Cat_Patch);
                Dr.DataBind();
                Dr.Visible = true;
            }
            else
            {
                if (DR_ID != "1")
                {
                    Dr.Items.Add("همه");
                    Dr.Items[0].Value = "0";
                }
                Dr.DataSource = new tbl_CategoryTableAdapter().GetDataByID_Root(ID_Category);
                Dr.DataBind();
                Dr.Visible = true;
            }
        }
        else
        {
            Dr.Items.Add("هیچکدام");
            Dr.Items[0].Value = "-2";
            Dr.DataBind();
            Dr.Visible = true;
        }
    }
    private void FillGrid()
    {
        int ID_Admin = int.Parse(Request.Cookies["ID_Role"].Value);
        DataTable dt2 = new tbl_AdminPermissionCategoryTableAdapter().GetDataByAPC_ID_Admin(ID_Admin);
        if (dt2.Rows.Count > 0)
        {
            string APC_Cat_Patch = dt2.Rows[0]["APC_Cat_Patch"].ToString();

            int ID = -1;
            if (Request.QueryString["ID_Root"] != null)
            {
                ID = int.Parse(Request.QueryString["ID_Root"]);
            }

            string[] discreteInfo2 = APC_Cat_Patch.Split(new char[] { ',' });
            int SathKarbar = 0;
            foreach (string Data2 in discreteInfo2)
            {
                SathKarbar++;
            }

            int SathJari = 0;
            DataTable dt = new tbl_CategoryTableAdapter().GetDataByID(ID);
            if (dt.Rows.Count > 0)
            {
                string delimitedInfo = dt.Rows[0]["Cat_Path"].ToString();
                string[] discreteInfo = delimitedInfo.Split(new char[] { ',' });
                foreach (string Data in discreteInfo)
                {
                    SathJari++;
                }
            }

            if (SathJari < SathKarbar && APC_Cat_Patch.Trim() != "-1")
            {
                GridView1.SelectedIndex = -1;
                GridView1.DataSource = new tbl_CategoryTableAdapter().GetDataByIDRootPermissionAdmin(ID, APC_Cat_Patch);
                GridView1.DataBind();
            }
            else
            {
                GridView1.SelectedIndex = -1;
                GridView1.DataSource = new tbl_CategoryTableAdapter().GetDataByID_Root(ID);
                GridView1.DataBind();
            }

            if (SathJari >= SathKarbar || APC_Cat_Patch.Trim() == "-1")
            {
                Button1.Enabled = true;
            }
            else
            {
                Button1.Enabled = false;

            }
            if (SathJari == 6 )
            {
                Button1.Enabled = false;
            }

        }
        else
        {
            GridView1.DataBind();

        }
    }