Guest User

Guest User

  • Tech Writer
  • 103
  • 13.3k

Set Pagination in c#.

Jun 2 2021 7:31 AM
Hello everyone how to implement Pagination in c# code .This is my code please let me know how to implement
var blogPosts = new List<BlogPostSummary>(customEntityResult.Items.Count());
foreach (var customEntity in customEntityResult.Items)
{
var model = (BlogPostDataModel)customEntity.Model;
var blogPost = new BlogPostSummary();
blogPost.Title = customEntity.Title;
blogPost.ShortDescription = model.ShortDescription;
DateTime tempDate = customEntity.CreateDate;
blogPost.PostDate = tempDate.ToString("MMMM dd, yyyy");
blogPost.FullPath = customEntity.PageUrls.FirstOrDefault();
blogPost.CategoryId = model.CategoryIds.SingleOrDefault();
blogPosts.Add(blogPost);
}
TempData["blogPostUrl"] = JsonConvert.SerializeObject(blogPosts);
return customEntityResult.ChangeType(blogPosts);

Answers (3)