在 DropDownList 的层次结构中显示类别和子类别
我必须在层次结构中的 dropdownlist
中显示类别和子类别,如下所示:
cat1
--cat11
----cat111
----cat112
----cat113
--cat12
----cat121
----cat122
----cat123
cat2
--cat21
----cat211
----cat212
----cat213
--cat22
----cat221
----cat222
----cat223
我必须从 SqlServer 数据库显示它,其中创建新类别和子类别时,它将反映在下拉列表中还。 我非常需要它。 请尽快回复。 提前致谢。 哈里奥姆。
I have to display the Category and SubCategory in the dropdownlist
in hierarchy, like as follows:
cat1
--cat11
----cat111
----cat112
----cat113
--cat12
----cat121
----cat122
----cat123
cat2
--cat21
----cat211
----cat212
----cat213
--cat22
----cat221
----cat222
----cat223
I have to display it from SqlServer database, in which when the new category and subcategory is created it will reflect in the dropdown also.
I need it very much.
Please response soon.
Thanks in advance.
hariom.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以按照以下步骤操作 -
在单个查询中查询类别和子类别,例如 -
禁用 cat 值 -
如果您想阅读完整的文章,请参阅我的博客上的这篇文章
http://suvendugiri。 wordpress.com/2012/08/26/asp-net-dropdownlist-containing-category-sub-category-hierarchy/
You may follow these steps -
Query both the categories and sub-categories in a single query like -
Disable cat values -
if you like to read a complete article then see this post on my blog
http://suvendugiri.wordpress.com/2012/08/26/asp-net-dropdownlist-containing-category-sub-category-hierarchy/
我建议您使用数据读取器来填充下拉列表。这将循环遍历类别。然后,您对每个类别执行单独的查询以获取子类别,然后创建项目。抱歉,现在无法执行示例代码!也许社区可以提供帮助?
I would suggest you use a datareader to populate the dropdownlist. This will loop through the categories. You then do a seperate query on each category to get the subcategories, and then create the items. Sorry can't do example code right now! Perhaps the community can help?