首页 > Web开发 > 详细

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

时间:2015-11-29 23:05:47      阅读:444      评论:0      收藏:0      [点我收藏+]

 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>{}
                        }
                    }
                }
            };
        }

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

原文:http://www.cnblogs.com/kezeguo/p/5005754.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!