GridView Paging and MembershipuserCollection

J

Jeff

hi

asp.net 3.5

I have a gridview on my webpage, which have paging enabled, and pagesize is
25.

the problem is that gridview doesn't show the links to go to next/previous
page. I suppose this have to do with setting the totalrecords correctly.
There are 480 users in the database, so it should atleast give 480/25 pages,
but none are displpayed

GridView:
<asp:GridView ID="gvwUsers" runat="server" Width="100%"
AlternatingRowStyle-BackColor="#FFFBD6" AllowSorting="true"
ShowHeader="true"
AutoGenerateColumns="false" AllowPaging="true" PageSize="25"
OnSorting="gvwUsers_Sorting"
OnRowDeleting="gvwUsers_RowDeleting" OnRowCreated="gvwUsers_RowCreated"
OnPageIndexChanging="gvwUsers_PageIndexChanging"
DataKeyNames="UserName">
<Columns>

Code that fills the GridView with data:
private void BindUsers(bool reloadAllUsers, int pageindex, int pagesize)
{
int totalRecords;
if (reloadAllUsers)
allUsers = Membership.GetAllUsers();


MembershipUserCollection users = null;
string searchText = "";
if (!string.IsNullOrEmpty(gvwUsers.Attributes["SearchText"]))
searchText = gvwUsers.Attributes["SearchText"];

bool searchByEmail = false;
Debug.WriteLine(gvwUsers.Attributes["SearchByEmail"].ToString());
if (!string.IsNullOrEmpty(gvwUsers.Attributes["SearchByEmail"]))
searchByEmail =
bool.Parse(gvwUsers.Attributes["SearchByEmail"]);

if (searchText.Length > 0)
{
if (searchByEmail)
users = Membership.FindUsersByEmail(searchText, pageindex,
pagesize, out totalRecords);
else
users = Membership.FindUsersByName(searchText, pageindex,
pagesize, out totalRecords);
}
else { users = allUsers; }

}


any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top