[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2107
  • Last Modified:

repeater to sitemap navigation

In ASP.net 2.0 with C# I have a repeater control that is nound to a sitemap.
I have a repeater and inside it another repeater and inside another repeater.
first level:  <asp:Repeater runat="server" ID="LeftMenu"   DataSourceID="SiteMapDataSource1">
second level: <asp:Repeater runat="server" ID="LeftsubMenu"      DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
third level:  <asp:Repeater runat="server" ID="LeftsubMenusub"     DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes %>'>
Actually In the second level I want it to run once with or without a repeater and I want to set it to childnode(1). How do I set it?

this is the web.sitemap:
siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
      <siteMapNode  title="rootHome"  url="~/default.aspx?p=304" description="">
            <siteMapNode siteMapFile="source.sitemap" />
            <siteMapNode siteMapFile="Everything.sitemap" />
      </siteMapNode>
</siteMap>
I want ro have a repeater only on everything.sitemap.
Thankyou
Anat

 
0
ANAT2403
Asked:
ANAT2403
  • 3
  • 2
  • 2
1 Solution
 
McExpCommented:
What effect are you actually trying to create?
0
 
REA_ANDREWCommented:
Have you not considered using a TreeView bound to the sitemap?

Andrew
0
 
McExpCommented:
looking at the names of your repeaters are you trying to create a menu, Why not use the asp:menu control?
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
ANAT2403Author Commented:
I thought of using the repeater because I have a prepared styling in css.
But the question is very simple:
In the repeater in the command:
 DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes
I want to write:
DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes[1]
but I get an error.
How do I write it correctly or how do I set the datasource of the repeater in the code behind to be on the second node?
Anat
0
 
REA_ANDREWCommented:
so in theory you want to datasource to be of the second node's child nodes:

pseudo:

DataSource='<%# ((SiteMapNode) Container.DataItem).ChildNodes[1].ChildNodes
0
 
McExpCommented:
I would probably not be using repeaters for this. How about adding a placeholder to your site and then using a function similar to the one I posted against your other question to naviagte the sitemap and then dynamically add controls to the placeholder.
0
 
ANAT2403Author Commented:
Hi REA ANDREW,
You where very close. I finally solved it but I put what you said in the page_load like this:
       SiteMapNodeCollection cNode = SiteMap.RootNode.ChildNodes[1].ChildNodes;
        LeftsubMenu.DataSource = cNode;
        LeftsubMenu.DataBind();
and I reduce the 3 repeaters to 2 and it worked.
Thankyou
anat
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now