These columns don't currently have unique values

Anyname Donotcare picture Anyname Donotcare · Mar 11, 2013 · Viewed 25.7k times · Source

I face the following problem : when i try to bind Telerik Treeview

These columns don't currently have unique values.


My code :

protected void BindRTV()
{
    rtv_acd.DataTextField = "name";
    rtv_acd.DataValueField = "main_id";
    rtv_acd.DataFieldID = "main_code";
    rtv_acd.DataFieldParentID = "father_code";
    rtv_acd.DataSource = dt;
    rtv_acd.DataBind();
}

Data snapshot :

enter image description here

How to fix this problem, i know that the main_code is repetitive but i want that .

Answer

Mohammad Dehghan picture Mohammad Dehghan · Mar 11, 2013

There is a parent-child relationship between nodes, and the relation works with values specified in DataFieldID and DataFieldParentID members. So you have to specify a field with unique values for DataFieldID member.

Suppose you have two nodes with ID (main_code) of 1 (you already have), and there is another node with parent ID (father_code) of 1. So which of the two nodes are the parent of this node?