search this blog [2700+ asp.net c# examples]

Loading...

How to use SiteMapDataSource in asp.net

asp.net SiteMapDataSource: how to use
SiteMapDataSource.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SiteMapDataSource.aspx.cs" Inherits="SiteMapDataSource" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net SiteMapDataSource: how to use</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Green">SiteMapDataSource</h2>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
        <asp:TreeView ID="TreeView1" runat="server">
        </asp:TreeView>
    </div>
    </form>
</body>
</html>
SiteMapDataSource.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class SiteMapDataSource : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.IsPostBack)
        {
            TreeView1.DataSourceID = "SiteMapDataSource1";
            TreeView1.ForeColor = System.Drawing.Color.Crimson;
        }
    }
}
Web.sitemap




Related asp.net example