jellybeannn -4 Junior Poster

Hi everyone, I've got a DepartmenstList and CategoriesList user controls, which works with stored procedures, when the a department is selected, only then is that departments categories listed. What I need help with is, when a department is selected I want the categories to display as a submenu to the selected department. I have no idea how to accomplish this with stored procedures involved.

Any help will be appreciated.

DepartmentsList.ascx

<asp:Repeater ID="Department" runat="server" >  
<HeaderTemplate>  
<ul>  
</HeaderTemplate>  
<ItemTemplate>  
<li>
      <asp:HyperLink ID="HyperLink1" Runat="server" 
      NavigateUrl='<%# Link.ToDepartment(Eval("DepartmentID").ToString())%>'
      Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
      ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'
      CssClass='<%# Eval("DepartmentID").ToString() == Request.QueryString["DepartmentID"] ? "DepartmentSelected" : "DepartmentUnselected" %>' />
</li>  
</ItemTemplate>  
<FooterTemplate>  
</ul>  
</FooterTemplate> 
</asp:Repeater>

DepartmentsList.ascx.cs

// Load department details into the DataList
    protected void Page_Load(object sender, EventArgs e)
    {
            // don't reload data during postback
        if (!IsPostBack)
        {
                // CatalogAccess.GetDepartments returns a DataTable object containing
                // department data, which is read in the ItemTemplate of the DataList
            Department.DataSource = CatalogAccess.GetDepartments();
                // Needed to bind the data bound controls to the data source
            Department.DataBind();
        }
     }

CategoriesList.ascx

<asp:Repeater ID="Category" runat="server" >  
<HeaderTemplate>  
<ul>  
</HeaderTemplate>  
<ItemTemplate>  
<li>
        <asp:HyperLink ID="HyperLink1" Runat="server" 
            NavigateUrl='<%# Link.ToCategory(Request.QueryString["DepartmentID"],Eval("CategoryID").ToString()) %>'
            Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
            ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'
            CssClass='<%# Eval("CategoryID").ToString() == Request.QueryString["CategoryID"] ? "CategorySelected" : "CategoryUnselected" %>' /> 
</li>  
</ItemTemplate>  
<FooterTemplate>  
</ul>  
</FooterTemplate> 
</asp:Repeater>

CategoriesList.ascx.cs

public partial class UserControls_CategoriesList : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
            // don't reload data during postback
        if (!IsPostBack)
        {
                // obtain the Id of the selected department
            string departmentId = Request.QueryString["DepartmentID"];
                // continue only if the DepartmentId exists in the query string
            if (departmentId != null)
            {
                    // Catalog.GetCategorieInDepartment(departmentId);
                    // object containg a category data, which is displayed by the dataList
                Category.DataSource =
                    CatalogAccess.GetCategoriesInDepartment(departmentId);
                    // needed to bind the data bound controls to the source
                Category.DataBind();
            }
        }
    }
}