I dont want to use asp.net’s TreeView control.
I want to create a custom template databound control with multi template support like –
<asp:MtNavigationControl>
<ItemTemplate>
...
...
</ItemTemplate>
<SelectedItemTemplate>
...
...
</SelectedItemTemplate>
<ParentItemTemplate>
...
...
</ParentSelectedItemTemplate>
<SelectedParentItemTemplate>
...
...
</SelectedParentSelectedItemTemplate>
</asp:MtNavigationControl>
My data is like –
class Employee
{
string EmployeeName
List<Employee> Employees
}
Does anyone know how to accomplish it? Please help !!!
Damn, I thought I might have found what I was looking for. I have the same question and I have it NEARLY complete. I am not sure if it is my class (TreeBranches) or the below class. Seems to work great on the initial render. But then each postback it seems to render things twice. I have tried things like Controls.Clear() but the .UniqueID’s seem to always be for a second set of control.
Basically, my TreeBranches is just a collection class for Branch objects. Quite similar to your Employee example. The Template is nothing more than the following:
It will generate a UL with LI’s below them. And if there is a nested Branch, a new UL will be contained in the LI that is the parent. This can be as deep as possible.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.ComponentModel;
using System.Collections;
namespace Website.Controls {
public partial class HeirarchicalList : System.Web.UI.UserControl {