This is a migrated thread and some comments may be shown as answers.

Save changes to treeview not working for me

0 Answers 40 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ciaran
Top achievements
Rank 1
Ciaran asked on 07 Feb 2013, 05:06 PM

I'm populating a treeview in c# asp.net and have bound data to it, all well and displays as it should. my problem now is that i'm looking to save any modifications to the checkboxes i.e if a user clicks an additional box and saves but i the checked state will stay false.

here's what i have so far which iterates through what was initially loaded and not what has been changed, I've tried many variations but haven't managed to get it working - anyone any ideas??

public void saveCheckedItems()
{

    if (treeListItems.CheckedNodes.Count > 0)
    {
        IList<RadTreeNode> allNodes = treeListItems.GetAllNodes();

        for (int i = 0; i < allNodes.Count; i++)
        {
            RadTreeNode node = (RadTreeNode)allNodes[i];
            string fileid = node.Value.ToString();
            if (node.Checked == true)
            {
                if (fileid.Length == 12)
                {
                    saveTreeChanges(Page.Request.QueryString["ID"], fileid,connectionStr);
                }
            }
        }
    }
}

edit -

creating treeview as follows

<telerik:RadTreeView ID="treeListItems" runat="server" CheckBoxes="True" Height="320px"
                            TriStateCheckBoxes="true" CheckChildNodes="true" Skin="WebBlue" CssClass="table table-bordered" OnNodeDataBound="RadTreeView1_NodeDataBound" >
                        </telerik:RadTreeView>

binding data like this

public void loadTreeList()
        {
            DataTable dt = treeMan.getTreeList(connectionStr);
            treeListItems.DataTextField = "Description";
            treeListItems.DataValueField = "FieldID";
            treeListItems.DataFieldID = "FieldID";
            treeListItems.DataFieldParentID = "ParentID";
            treeListItems.DataSource = dt;
            treeListItems.DataBind();
            treeListItems.ExpandAllNodes();
        }

in the example im testing its a 3 tier tree and one element is checked on third tier. When i click more items only this already checked item is visible in the list

No answers yet. Maybe you can help?

Tags
TreeView
Asked by
Ciaran
Top achievements
Rank 1
Share this question
or