First create a new xml file named menu with the following content:
<?xml version="1.0" encoding="utf-8" ?>
<menu>
<menuItem url="~/Default.aspx" title="Home" description=""/>
<menuItem url="~/News.aspx" title="News" description="">
<menuItem url="~/News.aspx" title="Domestic News" description=""/>
<menuItem url="~/News.aspx" title="International News" description=""/>
</menuItem>
</menu> Then drag and drop a menu control on the page, drag and drop an XmlDataSource control with the id XmlDataSource1, and set the menu's DataSourceID to XmlDataSource1.
Configure the XmlDataSource control so that DataFile="~/Menu.xml" XPath="menu/menuItem",
Here xpath is used to select data, that is, to filter out the menuItem data.
At this point, bind the data of the menu control and tell the menu control how to display the data filtered from the xml file. Select the menu control, select DataBindings in the properties window, in the pop-up dialog box, select menuItem in the list in the upper left corner, click the Add button to add menuItem to the list in the lower left, then select menuItem in this list, this is the right The list will show the properties to bind, so NavigateUrlField="url" TextField="title". Press the OK button to return to the design interface. At this time, the two menu items "Home" and "News" will be displayed.
The design html code is as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CoAffiliate._Default" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="Menu1" runat="server" DataSourceID="XmlDataSource1" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
<DataBindings>
<asp:MenuItemBinding DataMember="menuItem" NavigateUrlField="url" TextField="title" />
</DataBindings>
</asp:Menu>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/Menu.xml" XPath="menu/menuItem"></asp:XmlDataSource>
</div>
</form>
</body>
</html>
http://www.cnblogs.com/ofei/archive/2007/01/20/625745.html