Cassie Mod

Cassie Mod

  • NA
  • 488
  • 70.5k

repeater is empty afther third page and more

Mar 14 2017 9:28 AM
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.
 
  1. public partial class UsersControl : CompleetControl  
  2.   {  
  3.       protected Features Features;  
  4.       private User _user;  
  5.       private Guid _sessionId;  
  6.   
  7.       public int PageSize = 5;  
  8.       private static int _pageCount;  
  9.       private static int _userAmount;  
  10.   
  11.       protected void Page_Load(object sender, EventArgs e)  
  12.       {  
  13.           _sessionId = Guid.Parse(HttpContext.Current.Session["BWSESSION"].ToString());  
  14.   
  15.           try  
  16.           {  
  17.               if (PortalApplication == null)  
  18.                   return;  
  19.   
  20.               Features = new Features(PortalApplication.User);  
  21.               if (!Features.ReadUsers)  
  22.               {  
  23.                   PortalApplication.ExecuteCommand(PortalApplication.GetAfterErrorCommand(404));  
  24.                   return;  
  25.               }  
  26.   
  27.               if (!IsPostBack)  
  28.                   FillRptUsers();  
  29.   
  30.               AddUserHyperLink.NavigateUrl = PortalApplication.GetUrl(PortalApplication.GetCommandByName(ApplicationCommands.UserAdd).Url);  
  31.           }  
  32.           catch (Exception ex)  
  33.           {  
  34.               PortalApplication.HandleException(ex);  
  35.               ShowFailureText();  
  36.           }  
  37.       }  
  38.   
  39.       public void FillRptUsers()  
  40.       {  
  41.           var serviceProviderId = PortalApplication.User.serviceProviderId;  
  42.           var groupId = PortalApplication.User.groupId;  
  43.           var userResponse = PortalApplication.GetGroupUsers(serviceProviderId, groupId, UserFilter.Text, CurrentPage, (CurrentPage - 1) * PageSize, PageSize);  
  44.           var users = userResponse.Item1;  
  45.           _userAmount = userResponse.Item2;  
  46.   
  47.           if ((string) ViewState["SortOrder"] == KeyConstants.AscSortOrder)  
  48.               switch ((string)ViewState["SortColumn"])  
  49.               {  
  50.                   case KeyConstants.UserNameColumn:  
  51.                       users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();  
  52.                       break;  
  53.                   case KeyConstants.UserPhoneNumberColumn:  
  54.                       users = users.OrderBy(x => x.phoneNumber).ToList();  
  55.                       break;  
  56.                   case KeyConstants.UserInternalNumberColumn:  
  57.                       users = users.OrderBy(x => x.extension).ToList();  
  58.                       break;  
  59.                   case KeyConstants.UserLocationColumn:  
  60.                       users = users.OrderBy(x => x.departmentFullPath).ToList();  
  61.                       break;  
  62.                   case  KeyConstants.UserEmailColumn:  
  63.                       users = users.OrderBy(x => x.emailAddress).ToList();  
  64.                       break;  
  65.                   case KeyConstants.UserQueueColumn:  
  66.                       users = users.OrderBy(x => x.hasCallQueueService).ToList();  
  67.                       break;  
  68.               }  
  69.           else if ((string) ViewState["SortOrder"] == KeyConstants.DescSortOrder)  
  70.               switch ((string)ViewState["SortColumn"])  
  71.               {  
  72.                   case KeyConstants.UserNameColumn:  
  73.                       users = users.OrderByDescending(x => x.firstName).ThenByDescending(x => x.lastName).ToList();  
  74.                       break;  
  75.                   case KeyConstants.UserPhoneNumberColumn:  
  76.                       users = users.OrderByDescending(x => x.phoneNumber).ToList();  
  77.                       break;  
  78.                   case KeyConstants.UserInternalNumberColumn:  
  79.                       users = users.OrderByDescending(x => x.extension).ToList();  
  80.                       break;  
  81.                   case KeyConstants.UserLocationColumn:  
  82.                       users = users.OrderByDescending(x => x.departmentFullPath).ToList();  
  83.                       break;  
  84.                   case KeyConstants.UserEmailColumn:  
  85.                       users = users.OrderByDescending(x => x.emailAddress).ToList();  
  86.                       break;  
  87.                   case KeyConstants.UserQueueColumn:  
  88.                       users = users.OrderByDescending(x => x.hasCallQueueService).ToList();  
  89.                       break;  
  90.               }  
  91.           else  
  92.               users = users.OrderBy(x => x.firstName).ThenBy(x => x.lastName).ToList();  
  93.   
  94.           // Consistant numbers:  
  95.           foreach (var user in users)  
  96.               user.phoneNumber = CompleetApplication.E164ToLocal(user.phoneNumber);  
  97.   
  98.           var dataSource = new PagedDataSource  
  99.           {  
  100.               DataSource = users,  
  101.               AllowPaging = true,  
  102.               PageSize = PageSize  
  103.           };  
  104.           if (CurrentPage > dataSource.PageCount - 1)  
  105.               dataSource.CurrentPageIndex = CurrentPage - 1;  
  106.   
  107.           rptUsers.DataSource = dataSource;  
  108.           rptUsers.DataBind();  
  109.   
  110.           //nieuw   
  111.           _pageCount = dataSource.PageCount;  
  112.           //_pageCount = (userResponse.Item2/10) + 1;  
  113.           // tiill here   
  114.           SetPageControl(dataSource);  
  115.       }  
  116.   
  117.       public void SetPageControl(PagedDataSource dataSource)  
  118.       {  
  119.           var currentPageLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("currentPageLabel");  
  120.           var nextPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("nextButton");  
  121.           var prevPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("prevButton");  
  122.           var prevThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("prevThreePagesButton");  
  123.           var nextThreePagesButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("nextThreePagesButton");  
  124.           var firstPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("firstPageButton");  
  125.           var lastPageButton = (Button)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("lastPageButton");  
  126.           var currentPageOfTotalPagesLabel = (Label)rptUsers.Controls[rptUsers.Controls.Count - 1].Controls[0].FindControl("CurrentPageOfTotalPagesLabel");  
  127.   
  128.           nextPageButton.Visible = true;  
  129.           prevPageButton.Visible = true;  
  130.           prevThreePagesButton.Visible = true;  
  131.           nextThreePagesButton.Visible = true;  
  132.           firstPageButton.Visible = true;  
  133.           lastPageButton.Visible = true;  
  134.   
  135.   
  136.           currentPageLabel.Text = (CurrentPage + 1).ToString();  
  137.   
  138.   
  139.           if (Convert.ToInt32(currentPageLabel.Text) == _pageCount)  
  140.               currentPageLabel.Text = CurrentPage.ToString();  
  141.   
  142.           // shows current page of total pages   
  143.           currentPageOfTotalPagesLabel.Text = $"Page {currentPageLabel.Text} of {_pageCount}, items {(CurrentPage * 10) + 1}-" + $"{(CurrentPage * 10) + 10} of {_userAmount}";  
  144.   
  145.           if (CurrentPage + 1 >= dataSource.PageCount)  
  146.           {  
  147.               nextPageButton.Visible = false;  
  148.               nextThreePagesButton.Visible = false;  
  149.               lastPageButton.Visible = false;  
  150.           }  
  151.   
  152.           if (CurrentPage == 0)  
  153.           {  
  154.               prevPageButton.Enabled = false;  
  155.               prevPageButton.Text = " ";  
  156.               prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");  
  157.               prevPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");  
  158.   
  159.               prevThreePagesButton.Enabled = false;  
  160.               prevThreePagesButton.Text = " ";  
  161.               prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");  
  162.               prevThreePagesButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");  
  163.   
  164.               firstPageButton.Enabled = false;  
  165.               firstPageButton.Text = " ";  
  166.               firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BackgroundColor, "transparent");  
  167.               firstPageButton.Attributes.CssStyle.Add(HtmlTextWriterStyle.BorderWidth, "0");  
  168.           }  
  169.   
  170.           if (dataSource.PageCount == 1)  
  171.           {  
  172.               // old  
  173.               //prevPageButton.Visible = false;  
  174.               //currentPageLabel.Visible = false;  
  175.               //nextPageButton.Visible = false;  
  176.               //prevThreePagesButton.Visible = false;  
  177.               //nextThreePagesButton.Visible = false;  
  178.               //firstPageButton.Visible = false;  
  179.               //lastPageButton.Visible = false;  
  180.   
  181.               // nieuw  
  182.               prevPageButton.Visible = true;  
  183.               currentPageLabel.Visible = true;  
  184.               nextPageButton.Visible = true;  
  185.               prevThreePagesButton.Visible = true;  
  186.               nextThreePagesButton.Visible = true;  
  187.               firstPageButton.Visible = true;  
  188.               lastPageButton.Visible = true;  
  189.           }  
  190.       }  
  191.   
  192.       public int CurrentPage  
  193.       {  
  194.           get  
  195.           {  
  196.               var o = ViewState["_CurrentPage"];  
  197.               if (o == null)  
  198.                   return 0;  
  199.               return (int)o;  
  200.           }  
  201.   
  202.           set  
  203.           {  
  204.               ViewState["_CurrentPage"] = value;  
  205.           }  
  206.       }  
  207.   
  208.       protected void prevButton_Click(object sender, EventArgs e)  
  209.       {  
  210.           CurrentPage -= 1;  
  211.           FillRptUsers();  
  212.       }  
  213.   
  214.       protected void prevThreePagesButton_Click(object sender, EventArgs e)  
  215.       {  
  216.           CurrentPage -= 3;  
  217.           FillRptUsers();  
  218.       }  
  219.   
  220.       protected void firstPageButton_Click(object sender, EventArgs e)  
  221.       {  
  222.           CurrentPage = 0;  
  223.           FillRptUsers();  
  224.       }  
  225.   
  226.       protected void nextButton_Click(object sender, EventArgs e)  
  227.       {  
  228.           CurrentPage += 1;  
  229.           FillRptUsers();  
  230.       }  
  231.   
  232.       protected void nextThreePagesButton_Click(object sender, EventArgs e)  
  233.       {  
  234.           CurrentPage += 3;  
  235.           FillRptUsers();  
  236.       }  
  237.       protected void lastPageButton_Click(object sender, EventArgs e)  
  238.       {  
  239.           CurrentPage =_pageCount;  
  240.           FillRptUsers();  
  241.       }  
  242. }
 
 
 

Answers (1)