如何从Treeview选定节点上的SQL Server表中选择数据单击事件 [英] How to select data from SQL server table on treeview selected node click event

查看:132
本文介绍了如何从Treeview选定节点上的SQL Server表中选择数据单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在母版页左侧和右侧使用Treeview控件,并使用用户控件按Treeview中的选定节点显示现有产品.例如:
>移动
>三星
>诺基亚
>摩托罗拉
> TV
> Onida
>三星

问题:我想显示所有子产品都位于数据列表"用户控件中的一个父节点下,而其他选定的父子节点也是如此.所有数据都应来自树视图中的SQL Server表以及用户控件.

但是我不知道该怎么办?任何人都可以帮助我从中脱颖而出吗?

您能否提供链接或C#代码(我在ASP.NET 4.0中使用C#)?

Hi All,

I am using Treeview control in Master page left hand side and right hand side using user control to display existing product as per selected node in treeview. Ex:
>Mobile
>Samsung
>Nokia
>Motorola
>TV
>Onida
>Samsung

Problem: I want to display all the child product comes under one parent node in Datalist user control and same for the other selected parent and child node as well. All the data should come from SQL server table in treeview as well as user control.

But I have no clue how to do? Can anyone help me to come out from this?

Could you provide me the link or C# code(I''m using C# with ASP.NET 4.0)?

推荐答案

1)捕获TreeView.SelectedNodeChanged [TreeNode.Text [
1) Catch TreeView.SelectedNodeChanged[^] event and get the value of TreeNode.Text[^]
2) Write and execute a query like this:
SELECT * 
FROM Products
WHERE ProductName = @prodname


3)读取查询返回的数据,并为所选节点添加新节点.

另类:
从数据库填充TreeView控件 [ ^ ]

更多信息:
http://www.dreamincode.net/code/snippet922.htm [ http://www.dotnetspider.com/resources/30981-Binding-Treeview-from- database.aspx [ ^ ]
http://www.eggheadcafe.com/articles/treeview_databinding.asp [


3) Read data returned by query and add new nodes for selected node.

Alternative:
Populating a TreeView Control from the Database[^]

More at:
http://www.dreamincode.net/code/snippet922.htm[^]
http://www.dotnetspider.com/resources/30981-Binding-Treeview-from-database.aspx[^]
http://www.eggheadcafe.com/articles/treeview_databinding.asp[^]


这篇关于如何从Treeview选定节点上的SQL Server表中选择数据单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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