private void LoadModuleList2DDL()
        {
            ddlModuleList.Items.Clear();

            Modules module_obj = new Modules();
            DataTable dt = module_obj.GetAll(); //select all the nodes from DB
            ddlModuleList.DataSource = dt;
            ddlModuleList.DataTextField = "ModuleTitle";
            ddlModuleList.DataValueField = "ModuleID";
            ddlModuleList.DataBind();
            ddlModuleList.Items.Insert(0, new ListItem("- Chọn -", "0"));
            ddlModuleList.SelectedIndex = 0;           
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                _idx = Convert.ToInt32(Request.QueryString["idx"]);
                LoadControlTypeList2DDL();

                Modules module_obj = new Modules();
                Literal_ModuleName.Text = module_obj.GetModuleTitleByModuleId(_idx);
                MultiView1.ActiveViewIndex = 0;
            }

            PostBackOptions optionsSubmit = new PostBackOptions(btnOkay);
            btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); ";
            btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit);
        }
        private void FillDataInGrid()
        {
            string PortalId = ddlPortalList.SelectedValue;
            Modules module_obj = new Modules();
            DataTable dt = module_obj.GetModuleListByPortalId(PortalId);          

            if (dt.Rows.Count > 0)
            {
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
            else
            {
                dt.Rows.Add(dt.NewRow());
                GridView1.DataSource = dt;
                GridView1.DataBind();

                int TotalColumns = GridView1.Rows[0].Cells.Count;
                GridView1.Rows[0].Cells.Clear();
                GridView1.Rows[0].Cells.Add(new TableCell());
                GridView1.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                GridView1.Rows[0].Cells[0].Text = "No Record Found";
            }

        }
        private int UpdateData()
        {
            string ApplicationId = ddlApplicationList.SelectedValue;
            string ModuleTitle = txtModuleTitle.Text;

            bool AllTab = false, IsAdmin = false, IsDeleted = false, InheritViewPermissions = false;
            if (ckbAllTab.Checked)
                AllTab = true;
            if (ckbIsAdmin.Checked)
                IsAdmin = true;
            if (ckbIsDeleted.Checked)
                IsDeleted = true;
            if (ckbInheritViewPermissions.Checked)
                InheritViewPermissions = true;
            Modules module_obj = new Modules();
            int result = module_obj.Update(_idx, ApplicationId, ModuleTitle, AllTab, IsAdmin, IsDeleted, InheritViewPermissions);
            return result;                
           
        }
        private void LoadData()
        {
            Modules module_obj = new Modules();
            DataTable dt = module_obj.GetDetails(_idx);

            LoadApplicationList2DDL(Session["ApplicationId"].ToString());
            LoadPortalList2DDL(dt.Rows[0]["PortalId"].ToString());
            txtModuleTitle.Text = dt.Rows[0]["ModuleTitle"].ToString();
            ckbAllTab.Checked = Convert.ToBoolean(dt.Rows[0]["AllTabs"].ToString());
            ckbIsAdmin.Checked = Convert.ToBoolean(dt.Rows[0]["IsAdmin"].ToString());
            ckbIsDeleted.Checked = Convert.ToBoolean(dt.Rows[0]["IsDeleted"].ToString());
            ckbInheritViewPermissions.Checked = Convert.ToBoolean(dt.Rows[0]["InheritViewPermissions"].ToString());

            string ModuleId = dt.Rows[0]["ModuleId"].ToString();
            IframePermission.Attributes.Add("src", "admin_module_permission_edit.aspx?idx=" + _idx);
            IframeModuleController.Attributes.Add("src", "admin_module_controller.aspx?idx=" + _idx);
        }
        public CascadingDropDownNameValue[] GetModuleList(string knownCategoryValues, string category)
        {
            StringDictionary dataValues = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
            string PortalId = dataValues["PortalId"];
            Modules module_obj = new Modules();
            DataTable dt = module_obj.GetModuleListByPortalId(PortalId);

            List<CascadingDropDownNameValue> module_list = new List<CascadingDropDownNameValue>();
            foreach (DataRow dRow in dt.Rows)
            {
                string ModuleId = dRow["ModuleId"].ToString();
                string ModuleTitle = dRow["ModuleTitle"].ToString();
                module_list.Add(new CascadingDropDownNameValue(ModuleTitle, ModuleId));
            }
            return module_list.ToArray();
        }
        private void LoadData()
        {
            Modules module_obj = new Modules();
            DataTable dt = module_obj.GetDetails(_idx);

            LoadModuleList2DDL(dt.Rows[0]["ModuleID"].ToString());
            LoadPaneList2DDL(dt.Rows[0]["PaneName"].ToString());            
        }
        private int AddData()
        {           
            string PortalId = ddlPortalList.SelectedValue;
            if (ddlPortalList.SelectedValue == "0")
            {
                Response.Write("<script>alert('Vui lòng chọn ứng dụng');window.history.back();</script>");
                Response.End();
                return -1;
            }
            else
            {                
                Modules module_obj = new Modules();
                string ModuleTitle = txtName.Text;

                bool AllTab = false, IsAdmin = false, IsDeleted = false, InheritViewPermissions = false;
                if (ckbAllTab.Checked)
                    AllTab = true;
                if (ckbIsAdmin.Checked)
                    IsAdmin = true;
                if (ckbIsDeleted.Checked)
                    IsDeleted = true;
                if (ckbckbInheritViewPermissions.Checked)
                    InheritViewPermissions = true;

                int result = module_obj.Insert(PortalId, ModuleTitle, AllTab, IsAdmin, IsDeleted, InheritViewPermissions);
                return result;
            }
        }