RadTreeView for ASP.NET

RadTreeView Send comments on this topic.
DataFieldParentID Property
See Also  Example
Telerik.WebControls Namespace > RadTreeView Class : DataFieldParentID Property


Gets or sets the field name from a data source to determine the parent ID of the nodes to bind.

  

 

Namespace: Telerik.WebControls
Assembly: RadTreeView (in RadTreeView.dll)

Syntax

Visual Basic (Declaration) 
Public Overridable Property DataFieldParentID As String
Visual Basic (Usage)Copy Code
Dim instance As RadTreeView
Dim value As String
 
instance.DataFieldParentID = value
 
value = instance.DataFieldParentID
C# 
public virtual string DataFieldParentID {get; set;}

Example

Visual BasicCopy Code
Dim dbCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/TreeView/Data/Tree.mdb"))
dbCon.Open()

Dim adapter As New OleDbDataAdapter("SELECT * FROM Links", dbCon)
Dim ds As New DataSet()
adapter.Fill(ds)

RadTree1.DataTextField = "TextColumn"
RadTree1.DataValueField = "ValueColumn"
RadTree1.DataFieldID = "ID"
RadTree1.DataFieldParentID = "ParentID"

RadTree1.DataSource = ds
RadTree1.DataBind()
C#Copy Code
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 Links", dbCon);
DataSet ds =
new DataSet();
adapter.Fill(ds);

RadTree1.DataTextField =
"TextColumn"
RadTree1.DataValueField = "ValueColumn"
RadTree1.DataFieldID = "ID";
RadTree1.DataFieldParentID =
"ParentID";

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

Remarks

RadTreeView fully supports binding to IList datasources (DataSet, DataTable), so you can easily populate your treeview instance with only a few lines of code. The built-in data binding supports auto-binding from a a single self-referencing table with ID -> ParentID relation.

Properties and methods related to data binding:

DataSource - (mandatory) object. Set to an instance of a DataSet or a DataTable
DataMember - (optional) string. If the DataSource is a DataSet and DataMember is set, then RadTreeView assumes the DataTable with the respective name in the DataSet. Otherwise the first DataTable in the DataSet is used.
DataFieldID - (mandatory) string. The name of the DataColumn holding the ID value;
DataFieldParentID - (mandatory) string. The name of the DataColumn holding the ParentID value;

DataTextField (optional) - Gets or sets the field name from a data source to bind to the RadTreeNode Text property.

DataValueField (optional) - Gets or sets the field name from a data source to bind to the RadTreeNode Value property.
DataBind() - (mandatory) menthod. Call this method after you've set the aforementioned properties per your scenario.

Requirements

Platforms: Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also