TreeView CheckNodes doesnt maintain true status

2 posts, 0 answers
  1. Jesus
    Jesus avatar
    10 posts
    Member since:
    Apr 2013

    Posted 25 Apr 2013 Link to this post

    Ok so my problem is that I cant set the checkboxes from node on true state.

    my treeView is in a .ascx

    this is the event for my RadGrid at .aspx where I have my usercontrol.ascx as a Template for Edit Mode
    protected void dtg_ItemCreated(object sender, GridItemEventArgs e)
            {
                #region dtgCatalogos_ItemCreated
                if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
                {
                    if (e.Item.DataItem != null)
                    {
                        string name = e.Item.DataItem.ToString();// 
                        UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                        RadTreeView radTreeView = (userControl.FindControl("tvRoles") as RadTreeView);
                        radTreeView.DataSource = SOMEDATASOURCE1;
                        radTreeView.DataBind();
     
                        foreach (RadTreeNode node in radTreeView.Nodes)
                        {
                                 node.Checked = true;
                        }
                    }
                }
    }
    here I set the check nodes to TRUE

    but at the time I display the treeView it doesnt have any checked nodes

    this is my .ascx

    <telerik:RadTreeView runat="server"  ID="tvRoles" DataValueField="ProcesoId" DataTextField="ProcesoDescr" CheckBoxes="true" CheckChildNodes="true" TriStateCheckBoxes="true" CausesValidation="false" />

    please, someone knows what am I doing wrong?

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

    Posted 26 Apr 2013 Link to this post

    Hi,

    Try the following code.
    c#;
    protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
            if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {
                GridEditFormItem item = (GridEditFormItem)e.Item;
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                RadTreeView tree = (RadTreeView)userControl.FindControl("tvRoles");
                tree.DataSourceID = "SqlDataSource1";
                tree.DataBind();
               tree.DataBound+=new EventHandler(tree_DataBound);
             }
    }
    void  tree_DataBound(object sender, EventArgs e)
    {
        RadTreeView tree=(RadTreeView)sender;
        foreach (RadTreeNode node in tree.GetAllNodes())
        {
          node.Checked = true;
        }
    }

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top