How to change menu static display levels value in asp.net c#

Change static display levels value in Menu control
Menu is an asp.net web server control. menu control's StaticDisplayLevels property get or set the number of menu levels to display in a static menu. the StaticDisplayLevels property value data type is System.Int32. this integer value represents the number of menu levels to display in a static menu. this property default value is 1.

so by using this property we can specify the number of menu levels to display in a static menu. this is useful when we want to display more menu levels as static menu (display without mouse over).

the following asp.net c# example code demonstrate us how can we set or change the menu control's static menu levels number programmatically at run time in an asp.net application.
MenuStaticDisplayLevels.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        Menu1.StaticDisplayLevels = 2;
        Label1.Text = "StaticDisplayLevels Now 2";
    }
    protected void Button2_Click(object sender, System.EventArgs e)
    {
        Menu1.StaticDisplayLevels = 3;
        Label1.Text = "StaticDisplayLevels Now 3";
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to set, change static display levels value in Menu control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy; font-style:italic;">Menu Example: StaticDisplayLevels</h2>
        <asp:SiteMapDataSource 
             ID="SiteMapDataSource1" 
             runat="server"
             />
        <div style="height:325px">
            <asp:Label 
                 ID="Label1"
                 runat="server"
                 Font-Bold="true"
                 Font-Italic="true"
                 Font-Size="Large"
                 ForeColor="IndianRed"
                 >
            </asp:Label>
            <br /><br />
            <asp:Menu 
                 ID="Menu1" 
                 runat="server" 
                 DataSourceID="SiteMapDataSource1"
                 Font-Bold="true"
                 ForeColor="MediumSeaGreen"
                 >
            </asp:Menu>
        </div>
        <asp:Button 
             ID="Button1" 
             runat="server"
             ForeColor="SteelBlue"
             Text="StaticDisplayLevels 2"
             Height="45"
             OnClick="Button1_Click"
             Font-Bold="true"
             />
        <asp:Button 
             ID="Button2" 
             runat="server"
             ForeColor="SteelBlue"
             Text="StaticDisplayLevels 3"
             Height="45"
             OnClick="Button2_Click"
             Font-Bold="true"
             />
    </div>
    </form>
</body>
</html>
Web.sitemap
Web.sitemap source code here.