如何使用asp.net或vb按存储过程在单个下拉列表中绑定类别然后子类别绑定? [英] how to bind category then subcategory bind in single dropdown using asp.net or vb by store procedure?

查看:88
本文介绍了如何使用asp.net或vb按存储过程在单个下拉列表中绑定类别然后子类别绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表是 - :

类别字段是 - :

CategoryID,Category_Name,Category_Description

1 Science aaaaa

2语言lllll



子类别字段是 - :

SubCategoryID,CategoryID,SubCategory_Name,SubCategory_Description

1 1物理学pppppppppp

2 1科学ssssssssss

3 2印地语hhhh

4 2英语eeeeee

5 2数学mmmmmm







我想在下面的下拉列表中得到结果 -



科学(这是category_Name)

- 物理学(它是子科学) ategory_Name)

- 生物学(它是subcategory_Name)

Langauge(它是category_Name)

- 印地语(它是subcategory_Name)

- 英语(它是subcategory_Name)

--Maths(它是subcategory_Name)

My Table is-:
Category fields are-:
CategoryID, Category_Name, Category_Description
1 Science aaaaa
2 Language lllll

SubCategory fields are-:
SubCategoryID, CategoryID, SubCategory_Name, SubCategory_Description
1 1 Physics pppppppppp
2 1 Science ssssssssss
3 2 Hindi hhhh
4 2 English eeeeee
5 2 Maths mmmmmm



I want to result below in dropdown list-

Science(it is category_Name)
--Physics(it is subcategory_Name)
--Biology(it is subcategory_Name)
Langauge(it is category_Name)
--Hindi(it is subcategory_Name)
--English(it is subcategory_Name)
--Maths(it is subcategory_Name)

推荐答案

hi,< br $>


查看此查询:





Check this query :

Select q.CategoryID,q.SubCategoryID,q.Category_Name
FROM
(
Select CategoryID,0 as SubCategoryID,Category_Name
from Category 
Union ALL
Select  CategoryID,SubCategoryID,SubCategory_Name as Category_Name
from SubCategory 
) q
order by q.CategoryID,q.SubCategoryID,q.Category_Name



注意我刚刚使用了select查询,你可以根据需要应用你的where条件


Note i just used the select query you can apply your where conditions if needed


这篇关于如何使用asp.net或vb按存储过程在单个下拉列表中绑定类别然后子类别绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆