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
<asp:DataList ID="ddlist" CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
runat="server" OnItemCommand="ddlist_ItemCommand" >
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<HeaderTemplate>
<asp:Label ID="lblh" runat="server" Text="Business Catalogs" ></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnkbtn" runat="server" CommandArgument='<%# Eval("CAT_ID") %>' ></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
protected void ddlist_ItemCommand(object source, DataListCommandEventArgs e)
{
ContentPlaceHolder mcon = new ContentPlaceHolder();
mcon = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
LinkButton lnk = new LinkButton();
lnk = (LinkButton)e.Item.FindControl("lnkbtn");
int id = (int.Parse(lnk.CommandArgument));
ICollection Catlist = ProductManager.Get_Categories(int.Parse(Session["check"].ToString()), id);
if (Catlist.Count > 0)
{
//Label lbl = new Label();
//lbl = (Label)ddlist.FindControl("lblh");
//lbl.Text += ">" + lnk.Text;
j = j + 1;
Session["check"] = j.ToString();
Response.Write(Session["check"].ToString());
ddlist.DataSource = ((DataRowCollection)Catlist)[0].Table;
ddlist.DataBind();
for (int i = 0; i <= ddlist.Items.Count - 1; i++)
{
LinkButton hyp = new LinkButton();
hyp = (LinkButton)ddlist.Items[i].FindControl("lnkbtn");
hyp.Text = ((DataRowCollection)Catlist)[0].Table.Rows[i].ItemArray[1].ToString();
}
}
else
{
Response.Write(Session["check"].ToString());
Session["check"] = 2;
Response.Redirect("ViewProductInformation.aspx");
}
}
waiting for your reply