943,152 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 834
  • ASP.NET RSS
Mar 8th, 2010
0

menu and submenu with atored procedure

Expand Post »
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.NET Syntax (Toggle Plain Text)
  1. <asp:Repeater ID="Department" runat="server" >
  2. <HeaderTemplate>
  3. <ul>
  4. </HeaderTemplate>
  5. <ItemTemplate>
  6. <li>
  7. <asp:HyperLink ID="HyperLink1" Runat="server"
  8. NavigateUrl='<%# Link.ToDepartment(Eval("DepartmentID").ToString())%>'
  9. Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
  10. ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'
  11. CssClass='<%# Eval("DepartmentID").ToString() == Request.QueryString["DepartmentID"] ? "DepartmentSelected" : "DepartmentUnselected" %>' />
  12. </li>
  13. </ItemTemplate>
  14. <FooterTemplate>
  15. </ul>
  16. </FooterTemplate>
  17. </asp:Repeater>

DepartmentsList.ascx.cs
ASP.NET Syntax (Toggle Plain Text)
  1. // Load department details into the DataList
  2. protected void Page_Load(object sender, EventArgs e)
  3. {
  4. // don't reload data during postback
  5. if (!IsPostBack)
  6. {
  7. // CatalogAccess.GetDepartments returns a DataTable object containing
  8. // department data, which is read in the ItemTemplate of the DataList
  9. Department.DataSource = CatalogAccess.GetDepartments();
  10. // Needed to bind the data bound controls to the data source
  11. Department.DataBind();
  12. }
  13. }

CategoriesList.ascx
ASP.NET Syntax (Toggle Plain Text)
  1. <asp:Repeater ID="Category" runat="server" >
  2. <HeaderTemplate>
  3. <ul>
  4. </HeaderTemplate>
  5. <ItemTemplate>
  6. <li>
  7. <asp:HyperLink ID="HyperLink1" Runat="server"
  8. NavigateUrl='<%# Link.ToCategory(Request.QueryString["DepartmentID"],Eval("CategoryID").ToString()) %>'
  9. Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
  10. ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'
  11. CssClass='<%# Eval("CategoryID").ToString() == Request.QueryString["CategoryID"] ? "CategorySelected" : "CategoryUnselected" %>' />
  12. </li>
  13. </ItemTemplate>
  14. <FooterTemplate>
  15. </ul>
  16. </FooterTemplate>
  17. </asp:Repeater>

CategoriesList.ascx.cs
ASP.NET Syntax (Toggle Plain Text)
  1. public partial class UserControls_CategoriesList : System.Web.UI.UserControl
  2. {
  3. protected void Page_Load(object sender, EventArgs e)
  4. {
  5. // don't reload data during postback
  6. if (!IsPostBack)
  7. {
  8. // obtain the Id of the selected department
  9. string departmentId = Request.QueryString["DepartmentID"];
  10. // continue only if the DepartmentId exists in the query string
  11. if (departmentId != null)
  12. {
  13. // Catalog.GetCategorieInDepartment(departmentId);
  14. // object containg a category data, which is displayed by the dataList
  15. Category.DataSource =
  16. CatalogAccess.GetCategoriesInDepartment(departmentId);
  17. // needed to bind the data bound controls to the source
  18. Category.DataBind();
  19. }
  20. }
  21. }
  22. }
Similar Threads
Reputation Points: 6
Solved Threads: 0
Junior Poster
jellybeannn is offline Offline
108 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Visual Studio and MySQL External database
Next Thread in ASP.NET Forum Timeline: ASP.NET- Experts





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC