private void PopulateSortOptions() { var options = CommunityHelper.GetCommentSortOptions(); if (options.Any()) { rptSortOptions.DataSource = options; rptSortOptions.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { int page; int sortBy; if (int.TryParse(ResultPage, out page) && int.TryParse(SortBy, out sortBy)) { int pageSize = Constants.ARTICLE_COMMENTS_PER_PAGE; int totalResults; bool hasMoreResults; var sortOptions = CommunityHelper.GetCommentSortOptions(); CommentSortOption sortOption = null; try { sortOption = sortOptions[sortBy]; } catch { return; } // Fallback for no sorting if (sortBy == 0) { sortOption = new CommentSortOption { Value = Constants.TelligentCommentSort.CreateDate, SortAscending = true }; } var comments = TelligentService.ReadComments(BlogId, PostId, page, pageSize, sortOption, out totalResults, out hasMoreResults); if (comments.Any()) { commentsControl.Comments = comments; phMoreResults.Visible = hasMoreResults; } } }