J
Jeff
hi
asp.net 2.0
I have a class named Category which I want to implement the IHierarchyData
interface so I can display it in a treeview control
Originally Category has a method named GetCategories, which return all the
categories in the Category table, this methos was used when the table didn't
contain hierarchy data....
I wonder how to implement the method which actually retrieves the recods
from the DAL after the IHierarchyData interface is implemented.
Below is my problem code, where should I implement the code that collects
the categories from the DAL/database? I've studied this example without
figureing this out:
http://www.codeproject.com/KB/custo...ise=3&sort=Position&view=Quick&select=2520602
Here is my implementation
public class CategoryCollection : List<Category>, IHierarchicalEnumerable
{
public CategoryCollection() : base()
{
}
public IHierarchyData GetHierarchyData(object enumeratedItem)
{
return enumeratedItem as IHierarchyData;
}
}
******
public class Category : IHierarchyData
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private CategoryCollection _children;
public CategoryCollection children
{
get { return _children; }
set { _children = value; }
}
public Category(int id, string name, int parent, int maintype)
{
this.Id = id;
this.Name = name;
this.Parent = parent;
this.MainType = maintype;
}
private int _parent;
public int Parent
{
get { return _parent; }
set { _parent = value; }
}
private int _maintype;
public int MainType
{
get { return _maintype; }
set { _maintype = value; }
}
public IHierarchicalEnumerable GetChildren()
{
return _children;
}
public IHierarchyData GetParent()
{
}
public bool HasChildren
{
get
{
if (_children.Count > 0)
return true;
else
return false;
}
}
public string Path
{
get { return this.Id.ToString(); }
}
public object Item
{
get { return this; }
}
public string Type
{
get { return this.GetType().ToString(); }
}
public static List<Category> GetCategories()
asp.net 2.0
I have a class named Category which I want to implement the IHierarchyData
interface so I can display it in a treeview control
Originally Category has a method named GetCategories, which return all the
categories in the Category table, this methos was used when the table didn't
contain hierarchy data....
I wonder how to implement the method which actually retrieves the recods
from the DAL after the IHierarchyData interface is implemented.
Below is my problem code, where should I implement the code that collects
the categories from the DAL/database? I've studied this example without
figureing this out:
http://www.codeproject.com/KB/custo...ise=3&sort=Position&view=Quick&select=2520602
Here is my implementation
public class CategoryCollection : List<Category>, IHierarchicalEnumerable
{
public CategoryCollection() : base()
{
}
public IHierarchyData GetHierarchyData(object enumeratedItem)
{
return enumeratedItem as IHierarchyData;
}
}
******
public class Category : IHierarchyData
{
private int _id;
public int Id
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private CategoryCollection _children;
public CategoryCollection children
{
get { return _children; }
set { _children = value; }
}
public Category(int id, string name, int parent, int maintype)
{
this.Id = id;
this.Name = name;
this.Parent = parent;
this.MainType = maintype;
}
private int _parent;
public int Parent
{
get { return _parent; }
set { _parent = value; }
}
private int _maintype;
public int MainType
{
get { return _maintype; }
set { _maintype = value; }
}
public IHierarchicalEnumerable GetChildren()
{
return _children;
}
public IHierarchyData GetParent()
{
}
public bool HasChildren
{
get
{
if (_children.Count > 0)
return true;
else
return false;
}
}
public string Path
{
get { return this.Id.ToString(); }
}
public object Item
{
get { return this; }
}
public string Type
{
get { return this.GetType().ToString(); }
}
public static List<Category> GetCategories()