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

Getting value of checked nodes when using sitemap as declarative datasource

2 Answers 38 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 11 Jun 2013, 06:09 PM
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();
pagecfg.AppendLine("<pageconfig>");
IList<RadTreeNode> nodeCollection = rtvSitemap.CheckedNodes;
foreach (RadTreeNode node in nodeCollection)
{
    pagecfg.AppendLine(string.Format("<page title='{0}' url='{1}' />",node.Text, node.Value));   
}
pagecfg.AppendLine("</pageconfig>");

Where the sitemap file looks like:
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" 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" />
</siteMapNode>
</siteMap>

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>
                            </telerik:RadTreeView>

2 Answers, 1 is accepted

Sort by
0
Aaron
Top achievements
Rank 1
answered on 11 Jun 2013, 08:56 PM
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)); 
0
Boyan Dimitrov
Telerik team
answered on 14 Jun 2013, 03:31 PM
Hello,

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. 

 

Regards,
Boyan Dimitrov
Telerik
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.
Tags
TreeView
Asked by
Aaron
Top achievements
Rank 1
Answers by
Aaron
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or