TreeView 's node Click Event
-
Hello I've populated a tree view from a selfjoined table and now I want to handle the event such that when the user clicks a node, I should just show the data of that record in a formview. I've done something similar in a desktop application but got no idea how to do it here. OnNodeClick was the event in desktop's case but here I dont know how to handle this situation plz give me a few guidelines Thanks
Rocky You can't climb up a ladder with your hands in your pockets.
-
Hello I've populated a tree view from a selfjoined table and now I want to handle the event such that when the user clicks a node, I should just show the data of that record in a formview. I've done something similar in a desktop application but got no idea how to do it here. OnNodeClick was the event in desktop's case but here I dont know how to handle this situation plz give me a few guidelines Thanks
Rocky You can't climb up a ladder with your hands in your pockets.
u check once the selection node changed property of the treeview
-
u check once the selection node changed property of the treeview
-
u mean I should handle SelectedNodeChanged event right void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { //TreeNode }
Rocky You can't climb up a ladder with your hands in your pockets.
yes my fnd
-
yes my fnd
-
yes my fnd
Unable to cast object of type 'System.Web.UI.WebControls.TreeView' to type 'System.Web.UI.WebControls.TreeNode' Thats the error I'm getting, here's my code protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { TreeNode node = (TreeNode)sender; int id = Convert.ToInt32(node.Value); Categories objCat = new Categories(); objCat.Where.ID.Value = id; if (objCat.Query.Load()) { TextBox tb = FormView1.FindControl("CatNameTextBox") as TextBox; tb.Text = objCat.CatName; tb = FormView1.FindControl("DescriptionTextBox") as TextBox; tb.Text = objCat.Description; CheckBox ck = FormView1.FindControl("IsActiveChkBox") as CheckBox; ck.Checked = objCat.IsActive; } } what I wanna do is to take the TreeNode Object coz its text and value are the CategoryName and ID respectively. But its unable to cast it to treeNode. Now what??!!
Rocky You can't climb up a ladder with your hands in your pockets.
-
Unable to cast object of type 'System.Web.UI.WebControls.TreeView' to type 'System.Web.UI.WebControls.TreeNode' Thats the error I'm getting, here's my code protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e) { TreeNode node = (TreeNode)sender; int id = Convert.ToInt32(node.Value); Categories objCat = new Categories(); objCat.Where.ID.Value = id; if (objCat.Query.Load()) { TextBox tb = FormView1.FindControl("CatNameTextBox") as TextBox; tb.Text = objCat.CatName; tb = FormView1.FindControl("DescriptionTextBox") as TextBox; tb.Text = objCat.Description; CheckBox ck = FormView1.FindControl("IsActiveChkBox") as CheckBox; ck.Checked = objCat.IsActive; } } what I wanna do is to take the TreeNode Object coz its text and value are the CategoryName and ID respectively. But its unable to cast it to treeNode. Now what??!!
Rocky You can't climb up a ladder with your hands in your pockets.
Rocky# wrote:
TreeNode node = (TreeNode)sender;
Sender is a TreeView. So convert it to TreeView and from that find the node using FindNode method.
**$**herin Iranimose
-
Rocky# wrote:
TreeNode node = (TreeNode)sender;
Sender is a TreeView. So convert it to TreeView and from that find the node using FindNode method.
**$**herin Iranimose
-
but how will I know which node was clicked? how will I find the node that was clicked? Its EventArgs is having no info regarding that?
Rocky You can't climb up a ladder with your hands in your pockets.
The TreeViewControl.SelectedNode gives the selected node. You can use it in the SelectedNodeChanged Event of the TreeView.
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
The TreeViewControl.SelectedNode gives the selected node. You can use it in the SelectedNodeChanged Event of the TreeView.
Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot
-
but how will I know which node was clicked? how will I find the node that was clicked? Its EventArgs is having no info regarding that?
Rocky You can't climb up a ladder with your hands in your pockets.
hi, What about this
MyTreeView.SelectedNode
**$**herin Iranimose
-
hi, What about this
MyTreeView.SelectedNode
**$**herin Iranimose