protected void btnUpdateAll_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridItem item in dgrUserRole.Items)
                {
                    int      user_id    = ConvertUtility.ToInt32(item.Cells[0].Text);
                    int      command_id = ConvertUtility.ToInt32(item.Cells[1].Text);
                    int      portal_id  = ConvertUtility.ToInt32(item.Cells[2].Text);
                    CheckBox chkView    = (CheckBox)item.FindControl("chkView");
                    CheckBox chkAdd     = (CheckBox)item.FindControl("chkAdd");
                    CheckBox chkUpdate  = (CheckBox)item.FindControl("chkEdit");
                    CheckBox chkDelete  = (CheckBox)item.FindControl("chkDelete");
                    CheckBox chkWeb     = (CheckBox)item.FindControl("chkWeb");
                    CheckBox chkWap     = (CheckBox)item.FindControl("chkWap");
                    CheckBox chkSMS     = (CheckBox)item.FindControl("chkSMS");
                    CheckBox chkXzone   = (CheckBox)item.FindControl("chkXzone");
                    try
                    {
                        DataTable dtUserCommands = CommandController.GetCommandsForUserNotGroup(user_id, ConvertUtility.ToInt32(dropPortal.SelectedValue));
                        DataRow[] rowItems       = dtUserCommands.Select("CommandParentID = " + command_id);

                        foreach (DataRow row in rowItems)
                        {
                            UserController.UpdateUserPermissionByPortalID(ConvertUtility.ToInt32(row["UserID"]), ConvertUtility.ToInt32(row["CommandID"]), portal_id, chkWeb.Checked, chkWap.Checked, chkSMS.Checked, chkXzone.Checked, chkView.Checked, true, true, true);
                        }
                        try
                        {
                            UserController.UpdateUserPermissionByPortalID(user_id, command_id, portal_id, chkWeb.Checked, chkWap.Checked, chkSMS.Checked, chkXzone.Checked, chkView.Checked, chkAdd.Checked, chkUpdate.Checked, chkDelete.Checked);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    catch
                    {
                        lblUpdateStatus1.Text = MiscUtility.MSG_UPDATE_ERROR;
                    }
                }
                lblUpdateStatus1.Text = MiscUtility.MSG_UPDATE_SUCCESS;
                new DataCaching().RemoveAll();
            }
            catch
            {
                lblUpdateStatus1.Text = MiscUtility.MSG_UPDATE_ERROR;
            }
            lblUpdateStatus.Text = "";
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //Fill commands
            lstCommands.Items.Clear();

            if (!CurrentUser.IsSuperAdmin)
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, ConvertUtility.ToInt32(dropPortal.SelectedValue)), 0, CurrentUser.IsSuperAdmin);
            }
            else
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommands(), 0, CurrentUser.IsSuperAdmin);
            }

            DataTable dtUserCommands = CommandController.GetCommandsForUserNotGroup(userId, ConvertUtility.ToInt32(dropPortal.SelectedValue));

            foreach (DataRow row in dtUserCommands.Rows)
            {
                if (lstCommands.Items.FindByValue(row["CommandID"].ToString()) != null)
                {
                    lstCommands.Items.FindByValue(row["CommandID"].ToString()).Selected = true;
                }
            }

            DataTable dtReturnCommand = new DataTable();

            dtReturnCommand.Columns.Add("CommandID", typeof(String));
            dtReturnCommand.Columns.Add("PortalID", typeof(String));
            dtReturnCommand.Columns.Add("UserID", typeof(String));
            dtReturnCommand.Columns.Add("CommandParentID", typeof(String));
            dtReturnCommand.Columns.Add("CommandName", typeof(String));
            dtReturnCommand.Columns.Add("Level", typeof(String));
            dtReturnCommand.Columns.Add("Role_View", typeof(String));
            dtReturnCommand.Columns.Add("Role_Add", typeof(String));
            dtReturnCommand.Columns.Add("Role_Update", typeof(String));
            dtReturnCommand.Columns.Add("Role_Delete", typeof(String));
            dtReturnCommand.Columns.Add("UseForWeb", typeof(String));
            dtReturnCommand.Columns.Add("UseForWap", typeof(String));
            dtReturnCommand.Columns.Add("UseForSMS", typeof(String));
            dtReturnCommand.Columns.Add("UseForXzone", typeof(String));

            dtCommand = dtUserCommands;
            DataTable _dtReturnCommand = UserController.BuildRecursiveUserPermission(dtUserCommands, dtReturnCommand, userId, ConvertUtility.ToInt32(dropPortal.SelectedValue));

            dgrUserRole.DataSource = _dtReturnCommand;
            dgrUserRole.DataBind();
        }