This is a migrated thread and some comments may be shown as answers.

1 selected ites send 2 values in selectedValue

4 Answers 28 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Andy Green
Top achievements
Rank 2
Andy Green asked on 31 May 2016, 09:04 AM

I have a DDT binding server side to Id & Name, I also have checkboxes

rdtLocation.DataSource = locations;
rdtLocation.DataTextField = "Name";
rdtLocation.DataFieldID = "Id";
rdtLocation.DataValueField = "Id";
rdtLocation.DataFieldParentID = "ParentId";
rdtLocation.DataSource = locations;
rdtLocation.DataBind();

With one selected item when I look at the selectedValue I get a comma separated list containing 2 instances of the id. ie - "2,2"

See attached screen shot.

Why is this and what is the fix.

Andy

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 03 Jun 2016, 08:00 AM
Hello Andy,

I have tested different scenarios, but I was not able to replicate the issue with two duplicate ID values. Can you please provide some dummy data that replicates the issue and also the exact steps for reproducing it?

I am looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Andy Green
Top achievements
Rank 2
answered on 03 Jun 2016, 08:06 AM

For now I have a fix for this, using LINQ to select distinct.

var location = rdtLocation.SelectedValue.Split(',').Select(int.Parse).Distinct().ToList();

ANdy

0
Andy Green
Top achievements
Rank 2
answered on 06 Jul 2016, 12:03 PM

Hi, I need to revisit this.

What I'm finding is that if I change selections, I get both in the SelectedValue, so no I cant use the LINQ above, as the ID's are different. I read somewhere that the control has to be Ajaxified to stop this but cant find it now.

Any ideas?

Andy

0
Eyup
Telerik team
answered on 11 Jul 2016, 11:48 AM
Hello Andy,

I'm sending a sample web site to demonstrate that the SelectedValue should correctly return only the values of the checked items single time. Alternatively, you can traverse the RadDropDownTree1.EmbeddedTree.CheckedNodes collection and extract the values manually.

I hope this will prove helpful.

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
DropDownTree
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Konstantin Dikov
Telerik team
Andy Green
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or