Best way to build a control for a recursive relationship

H

hardieca

Hi,

I'm building a CMS and I'm banging my head against the wall over one
part of the user interface. I have a Section entity which maybe have 0
or 1 parent Sections.

So, as an example, I could have a "Media" section which is the parent
to a "New Release" section which is a parent to a "Recent Releases"
section. I need to build a control that expresses the recursive
relationship of each section to its parent, but it needs to be
flexible enough so that I can edit each section's properties, or add
child sections intuitively.

I have been trying to use a Repeater to emit a table, but the records
can't be grouped in a hierarchical relationship which would immensely
improve negotiating the structure of the site. A list springs to mind,
has anyone seen a control that does something like what I'm looking
for?

Regards,

Chris
 
P

Paul Cheetham

Hi Chris,

You need to use a Treeview type control.

I don't think there is a treeview in the standard control set, so check
out the one at www.telerik.com

We use their entire control set.



Paul
 
K

Kevin.Newsted

The UI setup in this case indeed looks like a typical treeview /
treelist control. The setup for creating this UI part with the
suggested telerik treeview control is indeed very easy - you just need
to populate a ADO.NET DataTable with the data needed and make sure you
have two additional columns for ID -> ParentID relation. Code can be
somethngi similar to this:


OleDbConnection dbCon = new OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/
TreeView/Data/Tree.mdb"));
dbCon.Open();

OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Nodes",
dbCon);
DataSet ds = new DataSet();
dapter.Fill(ds);

RadTree1.DataFieldID = "id";
RadTree1.DataFieldParentID = "parentId";

RadTree1.DataSource = ds;
RadTree1.DataBind();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top