请在我的ASP.NET代码中帮助我进行SQL查询 [英] Please Help me with SQL query in my ASP.NET code

查看:79
本文介绍了请在我的ASP.NET代码中帮助我进行SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网页中有一个树状视图,使用c#绑定到asp.net中的sql表. 我有一个保存按钮和一个用于表示节点名称的文本框,以及一个用于显示节点父级的下拉列表框.当我在节点中单击时,其父级的名称和名称将转到文本框和dropdownlistbox.
我想在sql中编写查询,以便当用户想要更改树视图中节点的父级时,该节点的子级是unselectable.so用户无法选择节点的任何子级作为其父级.我可以编写一个选择该节点的子级的查询,但我不知道II如何编写选择其他级别的子级的查询.

I have a treeview in my webpage bound to a sql table in asp.net using c#.
I have a save button and a textbox for the name of the node and a dropdownlistbox to show the parent of the node .when i click in the nodes the name and the name of its parent goes to the textbox and dropdownlistbox.
i want to write a query in sql so that when users want to change the parent of a node in treeview ,the children of that node be unselectable.so users are unable to select any children of a node as its parent.I can write a query that select the children of that node but I dont know how I I can write query that select the children of those in other levels.

推荐答案

这将从代码隐藏中完成.因此您不会从SQL上执行此操作,但建议您可以启用/禁用treeview节点.因此,更改父节点后,您可以禁用子节点.您可以在OnSelectedNodeChanged事件上执行此操作.

要禁用该节点,您可以执行以下操作:

This will be done from codebehind. so you wont be doing it from SQL but as a suggestion, you can enable/disable the treeview node. so when the parent node is changed you can disable the child nodes. You can do it on OnSelectedNodeChanged event.

To disable the node you can do is;

TreeNode node = new TreeNode();
node.SelectAction = TreeNodeSelectAction.None;



或其他方式;



or another way;

<asp:TreeView ID="MyTreeView" runat="server">
        <nodes>
                <asp:TreeNode SelectAction="None">
        </nodes>


这篇关于请在我的ASP.NET代码中帮助我进行SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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