C# 这些列目前没有唯一值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15339815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
These columns don't currently have unique values
提问by Anyname Donotcare
I face the following problem : when i try to bind Telerik Treeview
我面临以下问题:当我尝试绑定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 :
数据快照:
How to fix this problem, i know that the main_code
is repetitive but i want that .
如何解决这个问题,我知道这main_code
是重复的,但我想要那个。
采纳答案by Mohammad Dehghan
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.
节点之间存在父子关系,该关系适用于DataFieldID
和DataFieldParentID
成员中指定的值。所以你必须为DataFieldID
成员指定一个具有唯一值的字段。
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?
假设您有两个节点的 ID ( main_code
) 为1
(您已经拥有),并且还有另一个节点的父 ID ( father_code
) 为1
。那么这两个节点中哪个是这个节点的父节点呢?
回答by Chandy Kunhu
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
检查 Telerik 开发者论坛 [1] http://www.telerik.com/forums/fetching-distinct-rows-from-datatable-using-linq[2] http://www.telerik.com/forums/display-不同值[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.
在此 Telerik 还回答说您应该使用唯一的列键。
Another tweak may be selecting datatable as distinct values [4]http://www.telerik.com/forums/radtreeview-selectednode-value
另一个调整可能是选择数据表作为不同的值 [4] http://www.telerik.com/forums/radtreeview-selectednode-value
Contact them if you havent resolved this at developer forum
如果您还没有在开发者论坛上解决此问题,请与他们联系
回答by hadi tajdini
this is about sql table and primary key for your table and you have duplicate data in your table feld
这是关于您的表的 sql 表和主键,并且您的表字段中有重复的数据