<%@ Control Language="JScript" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ OutputCache Duration="3600" VaryByParam="selection" %>

<script runat="server">

    //*******************************************************
    //
    // The Page_Load event on this page is used to obtain
    // from a database a list of all product categories
    // and databind it to an asp:datalist control.
    //
    // To optimize performance, this user control is output 
    // cached (varying based on the categoryId and selection
    // passed through the querystring.    
    //
    //*******************************************************

    function Page_Load(sender: Object, e: EventArgs) : void {
       
        // Set the curent selection of list
        var selectionId : String  = Request.Params["selection"];

        if (selectionId != null) {
            MyList.SelectedIndex = Int32.Parse(selectionId);
        }

        // Obtain list of menu categories and databind to list control
        var products : IBuySpy.ProductsDB  =  new IBuySpy.ProductsDB();
        
        MyList.DataSource = products.GetProductCategories();
        MyList.DataBind();      
    }
	
</script>

<table cellspacing="0" cellpadding="0" width="145" border="0">
    <tr valign="top">
        <td colspan="2">
            <a href="default.aspx"><img src="images/logo.gif" border="0"></a>
        </td>
    </tr>
    <tr valign="top">
        <td colspan="2">
            <asp:DataList id="MyList" runat="server" cellpadding="3" cellspacing="0" width="145" SelectedItemStyle-BackColor="dimgray" EnableViewState="false">
                <ItemTemplate>
                    <asp:HyperLink cssclass="MenuUnselected" id="HyperLink1" Text='<%# DataBinder.Eval(Container.DataItem, "CategoryName") %>' NavigateUrl='<%# "productslist.aspx?CategoryID=" + DataBinder.Eval(Container.DataItem, "CategoryID") + "&selection=" + Container.ItemIndex %>' runat="server" />
                </ItemTemplate>
                <SelectedItemTemplate>
                    <asp:HyperLink cssclass="MenuSelected" id="HyperLink2" Text='<%# DataBinder.Eval(Container.DataItem, "CategoryName") %>' NavigateUrl='<%# "productslist.aspx?CategoryID=" + DataBinder.Eval(Container.DataItem, "CategoryID") + "&selection=" + Container.ItemIndex %>' runat="server" />
                </SelectedItemTemplate>
            </asp:DataList>
        </td>
    </tr>
    <tr>
        <td width="10">
             
        </td>
        <td>
            <br><br><br><br><br><br>
            <a href="docs/docs.htm" target="_blank" class="SiteLink">IBuySpy Store<br>Documentation</a>
        </td>
    </tr>
</table>