User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 361,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,059 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 266 | Replies: 0
Reply
Join Date: Apr 2007
Posts: 111
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
greeny_1984 greeny_1984 is offline Offline
Junior Poster

Control to display categories and subcategories

  #1  
May 21st, 2008
Hi,
I have a page containing categories and subcategories.
Iam using datalist to display categories.
I want ot get subcategories based on categories selected.
On clicking on again subcategories i need to display subsubcategories.
ex:
Agriculture
|
V
plantproducts
|
V
beans
|
V
green beans
|
V
product page.
a category can have any no of subcategories in it.
I want to display all this in a single page.
Cn anyone suggest what control to use for it and the procedure.My code is like this


  1. <asp:DataList ID="ddlist" CellPadding="5"
  2. CellSpacing="5"
  3. RepeatDirection="Vertical"
  4. RepeatLayout="Table"
  5.  
  6. runat="server" OnItemCommand="ddlist_ItemCommand" >
  7. <HeaderStyle BackColor="#aaaadd">
  8. </HeaderStyle>
  9.  
  10. <AlternatingItemStyle BackColor="Gainsboro">
  11. </AlternatingItemStyle>
  12.  
  13. <HeaderTemplate>
  14.  
  15.  
  16. <asp:Label ID="lblh" runat="server" Text="Business Catalogs" ></asp:Label>
  17.  
  18. </HeaderTemplate>
  19.  
  20. <ItemTemplate>
  21. <asp:LinkButton ID="lnkbtn" runat="server" CommandArgument='<%# Eval("CAT_ID") %>' ></asp:LinkButton>
  22.  
  23. </ItemTemplate>
  24. </asp:DataList>
  25.  
  26. protected void ddlist_ItemCommand(object source, DataListCommandEventArgs e)
  27. {
  28. ContentPlaceHolder mcon = new ContentPlaceHolder();
  29. mcon = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
  30. LinkButton lnk = new LinkButton();
  31. lnk = (LinkButton)e.Item.FindControl("lnkbtn");
  32. int id = (int.Parse(lnk.CommandArgument));
  33. ICollection Catlist = ProductManager.Get_Categories(int.Parse(Session["check"].ToString()), id);
  34. if (Catlist.Count > 0)
  35. {
  36. //Label lbl = new Label();
  37. //lbl = (Label)ddlist.FindControl("lblh");
  38.  
  39. //lbl.Text += ">" + lnk.Text;
  40. j = j + 1;
  41. Session["check"] = j.ToString();
  42. Response.Write(Session["check"].ToString());
  43. ddlist.DataSource = ((DataRowCollection)Catlist)[0].Table;
  44. ddlist.DataBind();
  45. for (int i = 0; i <= ddlist.Items.Count - 1; i++)
  46. {
  47. LinkButton hyp = new LinkButton();
  48. hyp = (LinkButton)ddlist.Items[i].FindControl("lnkbtn");
  49. hyp.Text = ((DataRowCollection)Catlist)[0].Table.Rows[i].ItemArray[1].ToString();
  50.  
  51.  
  52. }
  53.  
  54. }
  55. else
  56. {
  57. Response.Write(Session["check"].ToString());
  58. Session["check"] = 2;
  59.  
  60. Response.Redirect("ViewProductInformation.aspx");
  61. }
  62.  
  63. }
waiting for your reply
Last edited by peter_budo : May 24th, 2008 at 7:13 pm. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC