ComponentOne SiteMap for ASP.NET Web Forms
C1SiteMap Features / Data Binding
In This Topic
    Data Binding
    In This Topic

    This topic demonstrates how to bind SiteMap to SiteMapDataSource, XMLDataSource and C1SiteMapDataSource control.

    In the Designer

    Complete the following steps to populate the control using a SiteMapDataSource control.

    1. Select the SiteMap control and click the smart tag to open the SiteMap Tasks Menu.
    2. Open the Choose Data Source dropdown and select <New data source...>. This opens the Data Source Configuration Wizard with a SiteMapDataSource1 defined in the ID field.

    3. Select Site Map and click OK. This adds a SiteMapDataSource control to the Web Form.
    4. Right click the SiteMapDataSource control and click Properties.
    5. In the Properties Window, add the name of the SiteMapProvider. To know how to create a custom SiteMapProvider, please see Custom SiteMap Provider.

    Complete the following steps to populate the control using a XML Data.

    1. Select the SiteMap control and click the smart tag to open the SiteMap Tasks Menu.
    2. Open the Choose Data Source dropdown and select <New data source...>. This opens the Data Source Configuration Wizard and select XML File.

    3. In the Configure Data Source dialog box that appears, select the XML file under Data File and click OK.

    Complete the following steps to populate the control using Dialog BoxDataSource control.

    1. Add a C1SiteMapDataSource control to the form.
    2. Right click the C1SiteMapDataSource control and select Properties.
    3. Add the .sitemap file to the SiteMapFile Property in the Properties Window.
    4. Open SiteMap Tasks Menu.
    5. Open the Choose Data Source dropdown and select C1SiteMapDataSource1.

    In Source View

    Complete the following steps to bind the SiteMap Control using SiteMapDataSource Control.

    1. Add the following markup within the <form></form> tags.
      Copy Code
      <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" SiteMapProvider="C1CustomSiteMapProvider" />
      

    2. Set the DatasourceID inside the <cc1:C1SiteMap>tag.
      Copy Code
      <cc1:C1SiteMap ID="C1SiteMap1" runat="server" DataSourceID="SiteMapDataSource1">
      

    Complete the following steps to bind the SiteMap Control to XML Data.

    1. Add the following markup within the <form></form> tags.      
      Copy Code
      <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Menu_Structure.xml"></asp:XmlDataSource>
      

    2. Set the DatasourceID inside the <cc1:C1SiteMap> tag.       
      Copy Code
      <cc1:C1SiteMap ID="C1SiteMap1" runat="server" DataSourceID="XmlDataSource1">
      

    Complete the following steps to bind the SiteMap Control using C1SiteMapDataSource control.

    1. Add the following markup within the <form></form> tags.
      Copy Code
      <cc1:C1SiteMapDataSource ID="C1SiteMapDataSource1" runat="server" SiteMapFile="~/web1.sitemap" />
      

    2. Set the DatasourceID inside the <cc1:C1SiteMap> tag.
      Copy Code
      <cc1:C1SiteMap ID="C1SiteMap1" runat="server" DataSourceID="C1SiteMapDataSource1">
      
    See Also