コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PostsService posts = new PostsService();

            var postsData = posts.All().ToList();
            this.ListViewPosts.DataSource = postsData;
            this.ListViewPosts.DataBind();
        }
コード例 #2
0
        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();
        }