# Change DropDown Multiselect values from code

**URL:** <https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859>\
**Category:** Blazor Server\
**Created:** [March 5, 2020, 1:16pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859 "2020-03-05T13:16:02Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![flipswitchingmonkey](https://forum.radzen.com/user_avatar/forum.radzen.com/flipswitchingmonkey/32/2408_2.png) [@flipswitchingmonkey](https://forum.radzen.com/u/flipswitchingmonkey)\
**Post date:** [March 5, 2020, 1:16pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/1 "2020-03-05T13:16:02Z")

</div>

Hi,

is there any way to change the multiselect values from code after render? The selection never picks up the changes in the connected bound value (a List or IEnumerable in this case).

Maybe through jsinterop? Could I just call the same function (which one is it?) that you trigger when selecting a checkbox in the selection popup?

Thanks

---

<div class="post-metadata">

**Author:** ![flipswitchingmonkey](https://forum.radzen.com/user_avatar/forum.radzen.com/flipswitchingmonkey/32/2408_2.png) [@flipswitchingmonkey](https://forum.radzen.com/u/flipswitchingmonkey)\
**Post date:** [March 5, 2020, 5:06pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/2 "2020-03-05T17:06:13Z")

</div>

Ok this is really weird. The components do notice when I _add_ an item to the bound List (and check the box accordingly), but when I remove an item, they do _not_ uncheck anything. Is this a bug?

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [March 6, 2020, 7:55am UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/3 "2020-03-06T07:55:26Z")

</div>

One of the DropDowns in [this demo](https://blazor.radzen.com/dropdown) is using multiple selection. You can check/uncheck items and observe how bound multiple values are changed.

---

<div class="post-metadata">

**Author:** ![flipswitchingmonkey](https://forum.radzen.com/user_avatar/forum.radzen.com/flipswitchingmonkey/32/2408_2.png) [@flipswitchingmonkey](https://forum.radzen.com/u/flipswitchingmonkey)\
**Post date:** [March 6, 2020, 9:43am UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/4 "2020-03-06T09:43:20Z")

</div>

This really is very weird. In a simple test app everything works as expected, but moving the _same_ page to my project selections are only ever added, but never removed. Something odd is happening...

Edit: ....And now it's suddenly working. Wtf? I guess this is one of those things...

---

<div class="post-metadata">

**Author:** ![armineh](https://forum.radzen.com/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@armineh](https://forum.radzen.com/u/armineh)\
**Post date:** [August 26, 2020, 12:01am UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/5 "2020-08-26T00:01:04Z")

</div>

I am facing same issue with multi select dropdown.  
I am selecting a item in dropdown and then by button click want to reset dropdown value by removing selected item and selecting other item using code behind , values are setting properly but in UI is still showing both selections and is not removing the one which I did from code behind  
please advise if any workaround for this.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [August 26, 2020, 8:56am UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/6 "2020-08-26T08:56:11Z")

</div>

You need to update the property/field to which the Value of the DropDown is set. Check the [online demo](https://blazor.radzen.com/dropdown) for a reference.

---

<div class="post-metadata">

**Author:** ![armineh](https://forum.radzen.com/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@armineh](https://forum.radzen.com/u/armineh)\
**Post date:** [August 26, 2020, 2:20pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/7 "2020-08-26T14:20:46Z")

</div>

I am doing same as u mentioned and property value is setting properly but still in UI showing the d selection as well as new one even though property valueIEnumerable is having only 1 item ehile debuging.  
How to avoid seeing old value in UI.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [August 26, 2020, 3:24pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/8 "2020-08-26T15:24:18Z")

</div>

We can't help unless we see some code.

---

<div class="post-metadata">

**Author:** ![armineh](https://forum.radzen.com/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@armineh](https://forum.radzen.com/u/armineh)\
**Post date:** [August 26, 2020, 5:02pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/9 "2020-08-26T17:02:13Z")

</div>

sending code in attachment

 ![UI screenshot](https://forum.radzen.com/uploads/default/original/2X/4/4da4be3a0c59c8328a094fabf0c4eb06f19cd96d.jpeg) ![function to set dropdown|436x500, 100%]  
protected void BindModelValue(string control)  
{

```
            case "region":

                region = !region;
                userAccessModel.AccessLevel = 1;
                if (region)
                {
                    loc = false;
                    mc = false;
                    CurrentUserAccess.MCs = new List<string>() { "11111" };
                    CurrentUserAccess.Locs = new List<string>() { "11111" };
                    CurrentUserAccess.Depts = new List<string>() { "1111" };                        

                }
                break;
            case "mc":
                mc = !mc;
                if (mc)
                {
                    
                    loc = false;
                    region = false;
                    
                    CurrentUserAccess.MCs= new List<string>();

```

CurrentUserAccess.Locs = new List() { "11111"}; CurrentUserAccess.Depts = new List() { "1111" };  
}

```
                break;
            case "loc":

                loc = !loc;
                if (loc)
                {
                    mc = false;
                    region = false;
                    CurrentUserAccess.MCs = new List<string>();
                    CurrentUserAccess.Locs= new List<string>();
                    CurrentUserAccess.Depts = new List<string>() { "1111" } ;

                }

                break;

        }

    }

```

---

<div class="post-metadata">

**Author:** ![armineh](https://forum.radzen.com/letter_avatar_proxy/v4/letter/a/76d3ee/32.png) [@armineh](https://forum.radzen.com/u/armineh)\
**Post date:** [August 26, 2020, 5:46pm UTC](https://forum.radzen.com/t/change-dropdown-multiselect-values-from-code/2859/10 "2020-08-26T17:46:44Z")

</div>

and here is my controls on razor page

 ![Razor](https://forum.radzen.com/uploads/default/original/2X/8/812af64c7380b09b21d226b0e1b06b515e90b9b0.jpeg)

I just found that the issue is happening when I only havr single selected item in dropdown, if I select 2 or more then UI reseting proparly as expected according to property value set in code behind but if I select only one and try to change value from code behind in UI it will show previous selection as well as the ome set from code
