首页 > 学院 > 开发设计 > 正文

关于asp.net的一点小问题有谁帮忙解答一下?

2019-11-14 14:34:18
字体:
来源:转载
供稿:网友

 public IList<Category> Categories { get; set; }
        PRotected void Page_Load(object sender, EventArgs e)
        {

//这是静态给categories赋值,怎么动态赋值呢,就是连接数据库后查询数据绑定categories,使他的数据成下面一样显示
            Categories = new List<Category>
            {
                new Category
                {
                    Name = "category 1",
                    Children = new List<Category>
                    {
                        new Category
                        {
                            Name="category 1-1",
                            Children = new List<Category>{}
                        },
                        new Category
                        {
                            Name="category 1-2",
                            Children = new List<Category>{}
                        },
                    }
                },
                new Category{
                    Name ="category 2",
                    Children = new List<Category>{
                        new Category{
                            Name = "category 2-1",
                            Children = new List<Category>{}
                        },
                        new Category
                        {
                            Name = "category 2-2",
                            Children = new List<Category>{}
                        }
                    }
                }
            };
        }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表