c# - SQL如何把多层数据绑定到下拉菜单?

查看:155
本文介绍了c# - SQL如何把多层数据绑定到下拉菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

SQL如何把多层数据绑定到下拉菜单?

所有的数据只在一张表格里(或者三张表格也可以), 现在想实现如下的显示方式,请问如何办到呢?

SELECT [ClassID],classname FROM [ProSortTable] b Where [SortGrade]=1

Select classID,ClassDegree2,classname from [ProSortTable] a where a.ClassDegree2 in

(SELECT [ClassID] FROM [ProSortTable] b Where [SortGrade]=1)

Select classID,ClassDegree2,ClassDegree3,classname from [ProSortTable] c where c.ClassDegree3 in
(
(Select classID from [ProSortTable] a where a.ClassDegree2 in

    (Select [ClassID]  FROM [db_lidecomcn].[dbo].[ProSortTable] b Where [SortGrade]=1)

)
) Order by c.ClassDegree3

解决方案

自己解决了,原来多用一个 dataRelation就可以了,没想到这么简单。。。

ds.Relations.Add("ParentChild", ds.Tables["parentTable"].Columns["parentID"], ds.Tables["childTable"].Columns["parentID"],false);

        ds.Relations.Add("childDetails",ds.Tables["childTable"].Columns["childID"],ds.Tables["detailsTable"].Columns["childID"],false);
        

这篇关于c# - SQL如何把多层数据绑定到下拉菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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