Save and Load TreeView White SQL Server

3 posts, 1 answers
  1. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 02 Jul 2014 Link to this post

    hi

    Do you Have Sample SQL Server Code for treeview for this Example :

    http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/draganddropnodes/defaultcs.aspx

    whit drag and drop ،add Node,Add Child nod,Delete Node And Child، Rename node and Child،and etc....

  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2014 in reply to Mohamad Javad Link to this post

    Hi Mohamad Javad,

    Please have a look into the below code snippet which Add and Delete the Parent Node and Child Node of RadTreeView. Here I have set a RadioButtonList and OnSelectedIndexChanged event of that RadioButton I am performing the the above mentioned operation.

    ASPX:

    <asp:RadioButtonList ID="rbtnlstPerformOperations" runat="server" AutoPostBack="true"
        OnSelectedIndexChanged="rbtnlstPerformOperations_SelectedIndexChanged">
        <asp:ListItem Text="Add Node">
        </asp:ListItem>
        <asp:ListItem Text="Add ChildNode">
        </asp:ListItem>
        <asp:ListItem Text="Delete Node">
        </asp:ListItem>
        <asp:ListItem Text="Delete ChildNode">
        </asp:ListItem>
    </asp:RadioButtonList>

    C#:
    protected void rbtnlstPerformOperations_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (rbtnlstPerformOperations.SelectedItem.Text == "Add Node")
        {
            RadTreeNode node1 = new RadTreeNode();
            node1.Text = "Parent New Node1";
            RadTreeView1.Nodes.Add(node1);
        }
        else if (rbtnlstPerformOperations.SelectedItem.Text == "Add ChildNode")
        {
            RadTreeNode parentNode = (RadTreeNode)RadTreeView1.FindNodeByText("Search Folders");
            RadTreeNode childNode = new RadTreeNode();
            childNode.Text="New Child Node1";
            parentNode.Nodes.Add(childNode);
        }
        else if (rbtnlstPerformOperations.SelectedItem.Text == "Delete Node")
        {
            RadTreeNode parentNode = (RadTreeNode)RadTreeView1.FindNodeByText("Personal Folders");
            RadTreeView1.Nodes.Remove(parentNode);
        }
        else if (rbtnlstPerformOperations.SelectedItem.Text == "Delete ChildNode")
        {
            RadTreeNode parentNode = (RadTreeNode)RadTreeView1.FindNodeByText("Personal Folders");
            RadTreeNode childNode = (RadTreeNode)parentNode.Nodes.FindNodeByText("Drafts");
            parentNode.Nodes.Remove(childNode);
        }
    }

    In order to rename the node try to set the AllowNodeEditing property of RadTreeView as true and attach the OnNodeEdit event as follows.

    ASPX:

    <telerik:RadTreeView ID="RadTreeView1" runat="server" EnableDragAndDrop="True" OnNodeDrop="RadTreeView1_HandleDrop" OnClientNodeDropping="onNodeDropping" AllowNodeEditing="true" OnClientNodeDragging="onNodeDragging" MultipleSelect="true" EnableDragAndDropBetweenNodes="true" OnNodeEdit="RadTreeView1_NodeEdit">
    </telerik:RadTreeView>

    C#:
    protected void RadTreeView1_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
    {
        RadTreeNode nodeEdited = e.Node;
        nodeEdited.Text = e.Text;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohamad Javad
    Mohamad Javad avatar
    39 posts
    Member since:
    Jul 2014

    Posted 03 Jul 2014 Link to this post

    Very Thanks
Back to Top