CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.internet_explorer_web_controls Tags:
Item Type: NewsGroup Date Entered: 7/5/2004 6:21:06 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 62 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
whisky
Asp.Net User
Treeview click event7/5/2004 6:21:06 AM

0

Hi,

I have a webform with a treeview. The tree is populated from the db (Category table). When a user clicks a node then I want to get the corresponding Product name from the products table in the db.

Below is the code that I tried. It does postback but does't fill the label.


Private Sub TreeView5_SelectedIndexChange(ByVal sender As Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView5.SelectedIndexChange
Dim objConn As New SqlConnection(strConn)
objConn.Open()
Dim objDS As New DataSet

cmd = objConn.CreateCommand

cmd.CommandText = "SELECT * FROM CATEGORIES WHERE CATEGORYID=@CATID"

cmd.Parameters.Add("@CATID", TreeView5.GetNodeFromIndex(e.NewNode).ID)


Dim dr As SqlDataReader
dr = cmd.ExecuteReader

Do While dr.Read
Label3.Text = dr.Item("CategoryName") + "<br>"


Loop


objConn.Close()
End Sub


StephenCassels
Asp.Net User
Re: Treeview click event7/5/2004 11:41:12 AM

0

whisky,

big, and rye, come to mind......

You're best not trying to get at the ID value of a treenode; You should bind your primary key to the 'NodeData' attribute. You can do this in a number of ways, simplest would be in your sql query to return the id as 'NodeData'

You'd then use the selectednode.getAttribute('NodeData') method to return your pk.

If you debug your code as is, you'll probably see that the id value is null.

Also, when getting the node from index you want to get the index of the node that has been clicked and use its pk for your sql query, not the new node. So use e.Node, not e.NewNode.





Stephen
whisky
Asp.Net User
Re: Treeview click event7/5/2004 11:49:02 AM

0

Thanks for the response. I solved the problem before receiving your post. It works but is this the wrong way to do it?


Dim objConn As New SqlConnection(strConn)
objConn.Open()
Dim objDS As New DataSet

cmd = objConn.CreateCommand

cmd.CommandText = "SELECT * FROM CATEGORIES WHERE CATEGORYID=@CATID"
cmd.Parameters.Add("@CATID", TreeView5.GetNodeFromIndex(TreeView5.SelectedNodeIndex).ID())


Dim dr As SqlDataReader
dr = cmd.ExecuteReader


Do While dr.Read

name = dr.Item("CategoryName")
Loop
StephenCassels
Asp.Net User
Re: Treeview click event7/5/2004 1:15:35 PM

0

whisky,

I've used Id in the past and found it to be a bit flaky. The documentation says that the recommended spot for your data is the aforementioned 'NodeData'.






Stephen
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Writing Add-ins for Visual Studio .NET Authors: Les Smith, Pages: 523, Published: 2002
Programming C# 3.0 Authors: Jesse Liberty, Donald Xie, Pages: 587, Published: 2007
Access 2007 VBA Programmer's Reference Authors: Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Armen Stein, Pages: 1110, Published: 2007
Developing Microsoft Office Solutions: Answers for Office 2003, Office XP, Office 2000, and Office 97 Authors: Ken Bluttman, Pages: 586, Published: 2003
Programming Visual Basic .NET Authors: Jesse Liberty, Dave Grundgeiger, Pages: 541, Published: 2003

Web:
Know Dot Net - Handling TreeView & ComboBox Click Events There is a subtile anamoly regarding determination of which node was selected when when a TreeView node is clicked. In VB6 you could use the click event and ...
Add Mouse Click event to a TreeView: display full path : TreeView ... Add Mouse Click event to a TreeView: display full path : TreeView « GUI « VB.Net .
Treeview click event???? - ASP.NET Forums I am using the TreeView webcontrol(Microsoft.Web.UI.WebControls ). Now the problem is that in this treeview there is no click event, ...
.NET 247 No node click event in Windows.Forms.TreeView? Messages. Related Types. This message was discovered on microsoft.public.dotnet.languages.vb. ...
Invoke Treeview Click Event All I need is to know how to trigger the Treeview's Click event; it is ... TreeView doesn't have a Click event of its own; it just inherits ...

treeview onclick problem - ng.asp-net-forum ... treeview onclick problem, > ROOT > NEWSGROUP > Asp.Net Forum ... on any node but on the 3rd click, the onclick event is no longer triggered. ...
asp:menu click event not getting fired - ng.asp-net-forum ... NET Treeview click event not fired with radwindow close button .... Dim dr As IDataReader = Getting data here through IDataReader While dr. ...
Treeview expand node onmouseover - ng.asp-net-forum ... Right Click TreeView Node : C#, ASP.NET, Internet Explorer 7 However; This rigth click event is not tied to the TreeView Node, . ...
TreeView: TreeNode.ValuePath - does this string have a hidden ... The TreeView is really driving me nuts on this issue! .... The Image control does not have a Click event, but in situations where the Click ...
No postback on checkchanged event of treeview control - ng.asp-net ... No postback on checkchanged event of treeview control, > ROOT > NEWSGROUP ... click event on panel · anything new for control licensing? ...






set iframe's query string from code-behind

login failing with db error

registering users

security exception error

using background images in a webform

project contains different definitions for the namespace. how do i resolve this?

loading a picture from a file

running an exe from asp.net web app

index of a datarow

the table stretches when window is resized

vxml and .net

how to restart a service through a link-is it possible?

multi column combo box in asp.net

error 554 response

getting the file name

mac address

dropdownlist control

javascript to hide control when printing

call js in .net code

text overflow in div

how to split this. simple string

how to: click an anchor element from page_load?

basic oop design question

rewrite url and get parameters

opening aspx page in frames through hyperlink

advice on writing a good exception logger / tracker

compiler error message: cs0246

refresh only once on closed of sendemail.aspx

how do i edit a record with multiple tables, with a gridview ?

really need help here!

   
  Privacy | Contact Us
All Times Are GMT