//GET: /PolicyOtherGroupItemDataTableItem/List
        public ActionResult List(int id, int policyGroupId, string filter, int?page, string sortField, int?sortOrder)
        {
            PolicyOtherGroupItemDataTableItemsVM policyOtherGroupItemDataTableItemsVM = new PolicyOtherGroupItemDataTableItemsVM();

            //Check Policy Exists
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyGroupId);
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "ListGet";
                return(View("RecordDoesNotExistError"));
            }

            policyOtherGroupItemDataTableItemsVM.PolicyGroup = policyGroup;

            //Check PolicyOtherGroupHeader Exists
            PolicyOtherGroupHeader policyOtherGroupHeader = new PolicyOtherGroupHeader();

            policyOtherGroupHeader = policyOtherGroupHeaderRepository.GetPolicyOtherGroupHeader(id);
            if (policyOtherGroupHeader == null)
            {
                ViewData["ActionMethod"] = "ListGet";
                return(View("RecordDoesNotExistError"));
            }

            policyOtherGroupItemDataTableItemsVM.PolicyOtherGroupHeader = policyOtherGroupHeader;

            //Set Access Rights
            policyOtherGroupItemDataTableItemsVM.HasWriteAccess = false;
            RolesRepository rolesRepository = new RolesRepository();

            if (rolesRepository.HasWriteAccessToPolicyGroup(policyGroupId))
            {
                policyOtherGroupItemDataTableItemsVM.HasWriteAccess = true;
            }

            //SortField + SortOrder settings
            if (string.IsNullOrEmpty(sortField))
            {
                //Dynamically generated in proc
                sortField = string.Empty;
            }
            ViewData["CurrentSortField"] = sortField;

            if (sortOrder == 1)
            {
                ViewData["NewSortOrder"]     = 0;
                ViewData["CurrentSortOrder"] = 1;
            }
            else
            {
                ViewData["NewSortOrder"]     = 1;
                ViewData["CurrentSortOrder"] = 0;
            }

            DataTable policyOtherGroupItemDataTableItems = policyOtherGroupItemDataTableItemRepository.GetPolicyOtherGroupItemDataTableItems(
                id, policyGroup.PolicyGroupId, filter ?? "", sortField, sortOrder ?? 0, page ?? 1, ref policyOtherGroupItemDataTableItemsVM);

            policyOtherGroupItemDataTableItemsVM.PolicyOtherGroupItemDataTableItems = policyOtherGroupItemDataTableItems;

            return(View(policyOtherGroupItemDataTableItemsVM));
        }
        //Sortable List
        public DataTable GetPolicyOtherGroupItemDataTableItems(int id, int policyGroupId, string filter, string sortField, int sortOrder, int page, ref PolicyOtherGroupItemDataTableItemsVM policyOtherGroupItemDataTableItemsVM)
        {
            //query db
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            DataSet policyOtherGroupItemDataTableItems = new DataSet();

            string connectionStringName = Settings.getConnectionStringName();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("spDesktopDataAdmin_SelectPolicyOtherGroupItemDataTableRows_v1", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@PolicyOtherGroupHeaderId", id);
                    cmd.Parameters.AddWithValue("@PolicyGroupId", policyGroupId);
                    cmd.Parameters.AddWithValue("@Filter", filter);
                    cmd.Parameters.AddWithValue("@SortField", sortField);
                    cmd.Parameters.AddWithValue("@SortOrder", sortOrder);
                    cmd.Parameters.AddWithValue("@PageNumber", page);
                    cmd.Parameters.AddWithValue("@AdminUserGuid", adminUserGuid);
                    conn.Open();

                    SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                    adapter.Fill(policyOtherGroupItemDataTableItems);
                }
            }

            if (policyOtherGroupItemDataTableItems.Tables[1] != null)
            {
                DataTable dt = policyOtherGroupItemDataTableItems.Tables[1];

                int totalRecords = (from DataRow dr in dt.Rows select(int) dr["Record Count"]).FirstOrDefault();
                int pageSize     = 16;

                policyOtherGroupItemDataTableItemsVM.PageIndex  = page;
                policyOtherGroupItemDataTableItemsVM.PageSize   = pageSize;
                policyOtherGroupItemDataTableItemsVM.TotalCount = totalRecords;
                policyOtherGroupItemDataTableItemsVM.TotalPages = (int)Math.Ceiling(totalRecords / (double)pageSize);
            }

            return(policyOtherGroupItemDataTableItems.Tables[0]);
        }