且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在类别表中使用数据列表控件

更新时间:2023-11-25 08:07:58



您可以在两个sql语句中完成此操作.

以下查询将获取您的所有父类别.
Hi,

You can do it in two sql statements.

The below query will get all your parent categories.
Select id, name from categories where parentid is NULL



然后,当用户选择一个类别时,您便知道其ID,因此只需选择所有父类别与所选类别匹配的子类别.



Then when the user selects a category you know its Id, so then you just select all the child categories which have a parent category matching the selected category.

//Pass in parameter @ParentId which matches the Category clicked.
Select id, name from categories where parentid = @ParentId