·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> ASP.NET网站开发 >> 关于asp.net的一点小问题有谁帮忙解答一下?
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>{}
}
}
}
};
}