Getting value of checked nodes when using sitemap as declarative datasource

3 posts, 0 answers
  1. Aaron
    Aaron avatar
    38 posts
    Member since:
    Jul 2012

    Posted 11 Jun 2013 Link to this post

    Hi guys,
    Ultimately, I am trying to build an xml string from the checked nodes in the treeview, though I'm having issues trying to retrieve the text and value fields from checked nodes when I have the treeview control bound to a sitemapdatasource and I was hoping you could help me out.
    Thanks in advance!

    My code-behind looks like:
    StringBuilder pagecfg = new StringBuilder();
    IList<RadTreeNode> nodeCollection = rtvSitemap.CheckedNodes;
    foreach (RadTreeNode node in nodeCollection)
        pagecfg.AppendLine(string.Format("<page title='{0}' url='{1}' />",node.Text, node.Value));   

    Where the sitemap file looks like:
    <siteMap xmlns="" enableLocalization="true">
    <siteMapNode title="$resources:SiteMapLocalizations,HomePageTitle" url="~/default.aspx" description="$resources:SiteMapLocalizations,HomePageDescription" Expanded="false" />
    <siteMapNode title="$resources:SiteMapLocalizations,PartSectionTitle" url="" description="$resources:SiteMapLocalizations,PartSectionDescription" Expanded="true" >
    <siteMapNode title="$resources:SiteMapLocalizations,PartPageTitle" url="~/Pages/Production/ProdPart.aspx" description="$resources:SiteMapLocalizations,PartPageDescription" SecAccess="Production" />

    My markup is as follows:
    <telerik:RadTreeView ID="rtvSitemap" runat="server" DataSourceID="dsSiteMap" CheckBoxes="true" MultipleSelect="true" CheckChildNodes="True" DataModelID="Title" DataNavigateUrlField="Url">
                                    <DataBindings><telerik:RadTreeNodeBinding Expanded="true" TextField="title" ValueField="url" /></DataBindings>
  2. Aaron
    Aaron avatar
    38 posts
    Member since:
    Jul 2012

    Posted 11 Jun 2013 Link to this post

    I forgot to mention the main issue is that values in this line returns empty strings.
    pagecfg.AppendLine(string.Format("<page title='{0}' url='{1}' />",node.Text, node.Value)); 
  3. Boyan Dimitrov
    Boyan Dimitrov avatar
    1969 posts

    Posted 14 Jun 2013 Link to this post


    I am afraid that there is no property in your sitemap node objects to indicate which nodes are checked and therefore the collection of your checked nodes is empty. It seems that all your nodes are considered unchecked and therefore the collection is empty. 


    Boyan Dimitrov
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top