protected void Page_Load(object sender, EventArgs e) { PostsService posts = new PostsService(); var postsData = posts.All().ToList(); this.ListViewPosts.DataSource = postsData; this.ListViewPosts.DataBind(); }
protected void CategoryLink_Click(object sender, EventArgs e) { string categoryName = ((LinkButton)sender).Text; PostsService posts = new PostsService(); var postsData = posts.All() .Where(p => p.Categories.Any(c => c.CategoryName == categoryName)) .ToList(); this.ListViewPosts.DataSource = postsData; this.ListViewPosts.DataBind(); }