HI, ive got a strange question.
i have an aspx site with a repeater on it. The repeater doesn't work properly.
the first 2 pages works perfectly. The third and further doesn;t snow any result, but my datasource wich is used as the repeater datasource contains 10 items. Why isn't it showing in my page ????
Here is my code. and some extra information.
total amount of users is 1079.
10 users are shown on a page. so 1079/10 + 1 = 108 pages.
page 1 works fine
page 2 works fine
page 3 and futher don't show results.
- public partial class UsersControl : CompleetControl
- {
- protected Features Features;
- private User _user;
- private Guid _sessionId;
-
- public int PageSize = 5;
- private static int _pageCount;
- private static int _userAmount;
-
- protected void Page_Load(object sender, EventArgs e)
- {
- _sessionId = Guid.Parse(HttpContext.Current.Session["BWSESSION"].ToString());
-
- try
- {
- if (PortalApplication == null)
- return;
-
- Features = new Features(PortalApplication.User);
- if (!Features.ReadUsers)
- {
- PortalApplication.ExecuteCommand(PortalApplication.GetAfterErrorCommand(404));
- return;
- }
-
- if (!IsPostBack)
- FillRptUsers();
-
- AddUserHyperLink.NavigateUrl = PortalApplication.GetUrl(PortalApplication.GetCommandByName(ApplicationCommands.UserAdd).Url);
- }
- catch (Exception ex)
- {
- PortalApplication.HandleException(ex);
- ShowFailureText();
- }
- }
-
- public void FillRptUsers()
- {
- var serviceProviderId = PortalApplication.User.serviceProviderId;
- var groupId = PortalApplication.User.groupId;
- var userResponse = PortalApplication.GetGroupUsers(serviceProviderId, groupId, UserFilter.Text, CurrentPage, (CurrentPage - 1) * PageSize, PageSize);
- var users = userResponse.Item1;
- _userAmount = userResponse.Item2;
-
- if ((string) ViewState["SortOrder"] == KeyConstants.AscSortOrder)
- switch ((string)ViewState["SortColumn"])
- {
- case KeyConstants.UserNameColumn:
- users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();
- break;
- case KeyConstants.UserPhoneNumberColumn:
- users = users.OrderBy(x => x.phoneNumber).ToList();
- break;
- case KeyConstants.UserInternalNumberColumn:
- users = users.OrderBy(x => x.extension).ToList();
- break;
- case KeyConstants.UserLocationColumn:
- users = users.OrderBy(x => x.departmentFullPath).ToList();
- break;
- case KeyConstants.UserEmailColumn:
- users = users.OrderBy(x => x.emailAddress).ToList();
- break;
- case KeyConstants.UserQueueColumn:
- users = users.OrderBy(x => x.hasCallQueueService).ToList();
- break;
- }
- else if ((string) ViewState["SortOrder"] == KeyConstants.DescSortOrder)
- switch ((string)ViewState["SortColumn"])
- {
- case KeyConstants.UserNameColumn:
- users = users.OrderByDescending(x => x.firstName).ThenByDescending(x => x.lastName).ToList();
- break;
- case KeyConstants.UserPhoneNumberColumn:
- users = users.OrderByDescending(x => x.phoneNumber).ToList();
- break;
- case KeyConstants.UserInternalNumberColumn:
- users = users.OrderByDescending(x => x.extension).ToList();
- break;
- case KeyConstants.UserLocationColumn:
- users = users.OrderByDescending(x => x.departmentFullPath).ToList();
- break;
- case KeyConstants.UserEmailColumn:
- users = users.OrderByDescending(x => x.emailAddress).ToList();
- break;
- case KeyConstants.UserQueueColumn:
- users = users.OrderByDescending(x => x.hasCallQueueService).ToList();
- break;
- }
- else
- users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();
-
-
- foreach (var user in users)
- user.phoneNumber = CompleetApplication.E164ToLocal(user.phoneNumber);
-
- var dataSource = new PagedDataSource
- {
- DataSource = users,
- AllowPaging = true,
- PageSize = PageSize
- };
- if (CurrentPage > dataSource.PageCount - 1)
- dataSource.CurrentPageIndex = CurrentPage - 1;
-
- rptUsers.DataSource = dataSource;
- rptUsers.DataBind();
-
-
- _pageCount = dataSource.PageCount;
-
-
- SetPageControl(dataSource);
- }
-
- public void SetPageControl(PagedDataSource dataSource)
- {
- var currentPageLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("currentPageLabel");
- var nextPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("nextButton");
- var prevPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("prevButton");
- var prevThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("prevThreePagesButton");
- var nextThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("nextThreePagesButton");
- var firstPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("firstPageButton");
- var lastPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("lastPageButton");
- var currentPageOfTotalPagesLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("CurrentPageOfTotalPagesLabel");
-
- nextPageButton.Visible = true;
- prevPageButton.Visible = true;
- prevThreePagesButton.Visible = true;
- nextThreePagesButton.Visible = true;
- firstPageButton.Visible = true;
- lastPageButton.Visible = true;
-
-
- currentPageLabel.Text = (CurrentPage + 1).ToString();
-
-
- if (Convert.ToInt32(currentPageLabel.Text) == _pageCount)
- currentPageLabel.Text = CurrentPage.ToString();
-
-
- currentPageOfTotalPagesLabel.Text = $"Page {currentPageLabel.Text} of {_pageCount}, items {(CurrentPage * 10) + 1}-" + $"{(CurrentPage * 10) + 10} of {_userAmount}";
-
- if (CurrentPage + 1 >= dataSource.PageCount)
- {
- nextPageButton.Visible = false;
- nextThreePagesButton.Visible = false;
- lastPageButton.Visible = false;
- }
-
- if (CurrentPage == 0)
- {
- prevPageButton.Enabled = false;
- prevPageButton.Text = " ";
- prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");
- prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");
-
- prevThreePagesButton.Enabled = false;
- prevThreePagesButton.Text = " ";
- prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");
- prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");
-
- firstPageButton.Enabled = false;
- firstPageButton.Text = " ";
- firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");
- firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");
- }
-
- if (dataSource.PageCount == 1)
- {
-
-
-
-
-
-
-
-
-
-
- prevPageButton.Visible = true;
- currentPageLabel.Visible = true;
- nextPageButton.Visible = true;
- prevThreePagesButton.Visible = true;
- nextThreePagesButton.Visible = true;
- firstPageButton.Visible = true;
- lastPageButton.Visible = true;
- }
- }
-
- public int CurrentPage
- {
- get
- {
- var o = ViewState["_CurrentPage"];
- if (o == null)
- return 0;
- return (int)o;
- }
-
- set
- {
- ViewState["_CurrentPage"] = value;
- }
- }
-
- protected void prevButton_Click(object sender, EventArgs e)
- {
- CurrentPage -= 1;
- FillRptUsers();
- }
-
- protected void prevThreePagesButton_Click(object sender, EventArgs e)
- {
- CurrentPage -= 3;
- FillRptUsers();
- }
-
- protected void firstPageButton_Click(object sender, EventArgs e)
- {
- CurrentPage = 0;
- FillRptUsers();
- }
-
- protected void nextButton_Click(object sender, EventArgs e)
- {
- CurrentPage += 1;
- FillRptUsers();
- }
-
- protected void nextThreePagesButton_Click(object sender, EventArgs e)
- {
- CurrentPage += 3;
- FillRptUsers();
- }
- protected void lastPageButton_Click(object sender, EventArgs e)
- {
- CurrentPage =_pageCount;
- FillRptUsers();
- }
- }