/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void Page_Load(object sender, System.EventArgs e) { int callingUserID = SessionAdapter.GetUserID(); if (callingUserID == 0) { // anonymous, redirect Response.Redirect("default.aspx", true); } if (!Page.IsPostBack) { int rowCount = 0; int currentPage = HnDGeneralUtils.TryConvertToInt(Request["Page"]); if (currentPage == 0) { currentPage = 1; // reset # of rows in the session. rowCount = 0; } else { rowCount = SessionAdapter.GetTempResult <int>("MyThreadsRowCount"); } // check if the rowCount is valid if (rowCount <= 0) { // reload rowCount rowCount = UserGuiHelper.GetRowCountLastThreadsForUserAsDataView(SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), callingUserID, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), callingUserID); SessionAdapter.SetTempResult("MyThreadsRowCount", rowCount); } short pageSize = CacheManager.GetSystemData().PageSizeSearchResults; if (pageSize <= 0) { pageSize = 50; } int rowCountCapped = rowCount; if (rowCount > 500) { // maximum is 500 rowCountCapped = 500; lblCappingWarning.Visible = true; } int amountPages = (rowCountCapped / pageSize); if ((amountPages * pageSize) < rowCountCapped) { amountPages++; } plPageListBottom.AmountPages = amountPages; plPageListBottom.CurrentPage = currentPage; plPageListTop.AmountPages = amountPages; plPageListTop.CurrentPage = currentPage; lblAmountThreads.Text = rowCount.ToString(); DataView lastThreads = UserGuiHelper.GetLastThreadsForUserAsDataView(SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum), callingUserID, SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), callingUserID, pageSize, currentPage); rpThreads.DataSource = lastThreads; rpThreads.DataBind(); } }