سؤال

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 .

هل كانت مفيدة؟

المحلول

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?

نصائح أخرى

As Mohammad said you should have at least one unique key column (without repetition). If don't this error will happens when you try to set primary key.

Also take into consideration that you don't have blank rows in that table, that indeed consider as unique column and I had this error.

The best way is to get distinct rows with certain number of column of consideration.

Check with telerik developer forum [1] http://www.telerik.com/forums/fetching-distinct-rows-from-datatable-using-linq [2] http://www.telerik.com/forums/display-distinct-values [3] http://www.telerik.com/forums/adding-5000-distinct-record-for-a-column-based-on-which-grouping-is-done-causing-ie-crash

In this Telerik also replied that you should use a unique column key.

Another tweak may be selecting datatable as distinct values [4]http://www.telerik.com/forums/radtreeview-selectednode-value

Contact them if you havent resolved this at developer forum

this is about sql table and primary key for your table and you have duplicate data in your table feld

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top