1

我正在创建一个搜索页面,以便按用户名、批准状态以及他们当前是否被锁定来过滤用户。

                if (!string.IsNullOrEmpty(filterby))
        {
            int totalRecords;
            if (filterby == "all")
            {
                viewModel.PaginatedUserList = Membership.GetAllUsers(page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
            }
            else if (!string.IsNullOrEmpty(searchterm))
            {
                string query = searchterm + "%";
                if (filterby == "email")
                {
                    viewModel.PaginatedUserList = Membership.FindUsersByEmail(query, page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
                }
                else if (filterby == "username")
                {
                    viewModel.PaginatedUserList = Membership.FindUsersByName(query, page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
                }

                else if (filterby == "approval")
                {
                    viewModel.PaginatedUserList = (PaginatedList<MembershipUser>) Membership.GetAllUsers(page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby).Where(x => x.IsApproved == false);
                }
            }
        }

我得到“无法投射'WhereListIterator 1[System.Web.Security.MembershipUser]' to type 'Project.Core.Pagination.PaginatedList1 [System.Web.Security.MembershipUser]'类型的对象。” 每当我尝试通过批准进行搜索时。由于我仍在学习,我不太确定解决此问题的最佳行动方案。任何帮助,将不胜感激。

4

0 回答 0