CodeVerge.Net Beta


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

ASP.NET Web Hosting – 3 Months Free!
Free 3 Months



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 12/20/2007 9:58:59 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 35 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
sureshkumar.vee
Asp.Net User
Tree View Control12/20/2007 9:58:59 AM

0/0

Hai

 In my web from I have 1 Treeview control , two buttons(Add, Delete) and one label. I have binded data from database to treeview control. Now If I select any node , then I'm displaying that node using label control. Now I have to Add and Delete nodes to the treeview control using Add and Delete Buttons.

 Anyone help me

How to solve this..

 

Thanks in Advance..     
 

siva_sm
Asp.Net User
Re: Tree View Control12/20/2007 12:09:16 PM

0/0

Amanda Wang - M
Asp.Net User
Re: Tree View Control12/24/2007 4:16:57 AM

0/0

Hi, 

sureshkumar.veesam:
Now If I select any node , then I'm displaying that node using label control. Now I have to Add and Delete nodes to the treeview control using Add and Delete Buttons.

1. If you want to display the selectednode in the label control, you can write some in the SelectedNodeChanged event, like below:

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        this.lbl.Text = this.TreeView1.SelectedNode.Text;
    }

2. If you want to add the node, you can do like below:

 protected void Button1_Click(object sender, EventArgs e)
    {
        TreeNode tn = new TreeNode("New Node", "New", "defaut.aspx");
        //this.TreeView1.Nodes.Add(tn);// add the node at the rootnode

        //add the node in some treenode.===========
        TreeNode parentNode = (TreeNode)this.TreeView1.FindNode("Home");
        parentNode.ChildNodes.Add(tn);

====================================

    }

3. If you want to deleted the nodes, you can use the remove method, like below:

protected void Button1_Click(object sender, EventArgs e)
    {
               TreeNode tn = (TreeNode)this.TreeView1.FindNode("Home");
        this.TreeView1.Nodes.Remove(tn);

    }

 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
sureshkumar.vee
Asp.Net User
Re: Tree View Control12/24/2007 5:15:48 AM

0/0

 Hai Mr. Amanda

Thanks for your reply

Once try this code please...

 

protected void Page_Load(object sender, EventArgs e)
    {

        fill_Tree();
    }
    public void fill_Tree()
    {
        SqlConnection con = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Treeview;Data Source=SYS2");
        con.Open();
        SqlCommand SqlCmd = new SqlCommand("Select * from Parent", con);
        SqlDataReader Sdr = SqlCmd.ExecuteReader();
        SqlCmd.Dispose();
        string[,] ParentNode = new string[100, 2];
        int count = 0;
        while (Sdr.Read())
        {
            ParentNode[count, 0] = Sdr.GetValue(Sdr.GetOrdinal("ParentID")).ToString();
            ParentNode[count++, 1] = Sdr.GetValue(Sdr.GetOrdinal("ParentName")).ToString();
        }
       
        Sdr.Close();
        for (int loop = 0; loop < count; loop++)
        {
            TreeNode root = new TreeNode();
            root.Text = ParentNode[loop, 1];
            root.Target = "_blank";
            root.NavigateUrl = "TreeView.aspx";
            SqlCommand Module_SqlCmd = new SqlCommand("Select * from Child where ParentId =" + ParentNode[loop, 0], con);
            SqlDataReader Module_Sdr = Module_SqlCmd.ExecuteReader();
            while (Module_Sdr.Read())
            {
                TreeNode child = new TreeNode();
                child.Text = Module_Sdr.GetValue(Module_Sdr.GetOrdinal("ChildName")).ToString();
                // child.Target = "_blank";
                // child.NavigateUrl = "your_page_Url.aspx";
                root.ChildNodes.Add(child);
            }
            Module_Sdr.Close();
            TreeView1.Nodes.Add(root);
          //  lblMsg.Text = TreeView1.SelectedValue;
        }
        TreeView1.CollapseAll();
        con.Close();
        
    }
    protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        this.lblMsg.Text = this.TreeView1.SelectedNode.Text;
    }

 Tables

Parent

ParentId      ParentName

1                Names
2                Id

Child

ParentId      ChildName

1                 Sachin
1                 Sourav
1                 Rahul
2                  101
2                  102
2                  103

When I'm selecting a node, The Treeview is again gets binding...Try this .....     

Amanda Wang - M
Asp.Net User
Re: Tree View Control12/24/2007 5:37:19 AM

0/0

 Hi,

You should adjust the Ispostback in the load event<

like below:

protected void Page_Load(object sender, EventArgs e)
    {

if(!IsPostback)

{

        fill_Tree();

}
    }

So it will not bind the treeview when you select  a node.

 

Hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Sams Teach Yourself Visual Basic 2005 in 24 Hours: Complete Starter Kit Authors: James D. Foxall, Pages: 536, Published: 2006
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Visual Basic.Net by Example Authors: Gabriel Oancea, Robert P. Donald, Pages: 976, Published: 2002
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
Developing Microsoft Office Solutions: Answers for Office 2003, Office XP, Office 2000, and Office 97 Authors: Ken Bluttman, Pages: 608, Published: 2003
Microsoft Visual C# 2005 Unleashed Authors: Kevin Hoffman, Pages: 692, Published: 2006
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Beginning Visual Basic 2005 Express Edition: From Novice to Professional Authors: Peter Wright, Pages: 520, Published: 2006

Web:
Yahoo! UI Library: TreeView The YUI TreeView Control provides a rich, compact visual presentation of ... Download: Download the TreeView Control as part of the full YUI Library on ...
CodeGuru: Treeview Control The view is compatible with the tree control of the common control. .... Learn about an advanced control based on a standard tree view control. ...
15 Seconds : Populating the TreeView Control from a Database Populating the TreeView Web Control from a database allows menu and input trees to change on the fly. Don Schlichting provides an introduction to the ...
Introduction to Tree View Control Introduction to Tree View Control C# Help c-sharp.
TreeView Control - developerFusion - the global developer community The Tree View control is a Visual Basic version of the control you see used in many programs, including Explorer and FrontPage, used to list the folders on ...
ASP.NET.4GuysFromRolla.com: Using the TreeView Control and a ... Aug 30, 2006 ... This article, by Scott Mitchell, looks at how to use the ASP.NET 2.0 TreeView control and DataList to create a simple and easily ...
Ajax TreeView Sample This is an example of our Ajax TreeView Control. The Gaia Ajax TreeView Control ... As you can see, this is not the case for our Gaia Ajax TreeView Control ...
15 Seconds : The ASP.NET 2.0 TreeView Control Thiru Thangarathinam introduces ASP.NET 2.0's new TreeView control which provides a seamless way to consume and display information from hierarchical data ...
Tree View Creates a dragging bitmap for the specified item in a tree-view control. .... Sets the extended style for a specified TreeView control. ...
Build a TreeView Control in Less Than Two Minutes with Visual ... May 17, 2005 ... Visual Studio 2005 Beta 2 provides a wide variety of new features and enhancements. One in particular that you may find useful is the ...

Videos:
One Note Tree View Control Control to navigate the notebooks in treeView
Visual Basic IV : TreeView Control - Shalvin Visual Basic IV : TreeView Control (Without Voice) - Shalvin
Using TreeView Control VB2008 and VB2005 http://www.vb-heaven.com
Tree View Learn how the TreeView control has been improved and its programming model simplified, allowing you to easily read and manipulate hierarchical data s...
Customized rad treeview control with checkboxes Handling a role permission matrix using telerik rad treeview control with customized checkboxes table
Sylvania Stay Lit 9' Christmas Tree with Remote Control For More Info or to Buy Now: http://www.hsn.com/redirect.aspx?id=il&url=http%3A//www.hsn.com/cnt/prod/default.aspx%3Fpfid%3D329958&afsrc=1&sourceid=y...
Christmas Lights control by C-64 Computer, house view I had Christmas lights controlled by a Commodore 64 computer in 1985, and it is still being used this year. Munster, Indiana, Dogwood at Camelia, abo...
Protecting Lake Superior: Classical musicians rally for Great Lake July 15, 2007 during free benefit concert Protecting Lake Superior: Free Michigan concert with classical musicians, dancer will benefit Lake Superior Defense Fund on July 15 (Marquette, Mich...
The Gathering of One ... Sow the Seeds of Peace The world joins together to create a global shift on the summer solstice 2008 to usher in the Golden Age of Peace. Centered at West Yellowstone Monta...
Meet Dede Koswara, the "Tree Man". From ABC News An Indonesian man suffers from Immune defficiency and HPV, a virus that in his case, has gone out of control. Literally. AMAZING!!!




Search This Site:










asp.net 2.0 treeview autopostback problem

customizing layout of wizard control

css styles not appearing in visual studio 2008 design time

masterpage messes up my css

how to add footer image below div wrapper image using css?

how can i access anyone control on another page?

treemenu, hyperlink & sitemap

how to change image link frommaster page?

auto-loading multiple content areas in 1 master page

new at this, help with master pages and content place holder in content pages

extending treenodecollection, sealed classes??

contentplaceholder obscures content in design mode

menu item customization

sitemap and security trimming

changing layout dynamically

master page images

databinding expressions are only supported on objects that have a databinding event.

can't call selectsinglenode on sitemap xml

master/child page postback event

controls inside wizard headertemplate

problems when publish a master page website.

how to format menu as a tabstrip with submenu as a second bar of links

master page problem at the time of deployment

masterpage - auto-open html link in content window

how do i keep static menu item highlighted until a selection is made?

<@ master> does not have a theme attribute?

how to code masterpage events?

navigateurl property and menuitemclick event responding

can someone please clarify this question with my sitemap

ie8 doesn't seem to like the asp.net menu control.

  Privacy | Contact Us
All Times Are GMT