Multiple DopDownListFor sharing same Datasource

Hi There,

I have a MVC Ajax form containing a bunch of DropDownListFor elements sharing the same Datasource located in ViewBag.
Unfortunately, if I select from one DropDownList, all the other DropDowns are taking over this very selected value.

Does anyone know how to segregate the selected content of each DropDownList from each other even if the Datasource is shared?

Thanks in advance
Markus

1 Reply

KR Keerthana Rajendran Syncfusion Team March 28, 2018 11:58 AM UTC

Hi Markus,   
   
Thank you for contacting Syncfusion Support.   
   
We have prepared a sample similar to your scenario with two DropDownList For sharing the same dataSource. When I select an item only the corresponding DropDownList is updated. If you wish to check the get the id of DropDownList from where selection is made you can get the id through select event as shown below.   
   
<div class="row">   
    @using (Ajax.BeginForm("Get""Home"new AjaxOptions { HttpMethod = "POST"}))   
    {   
    @Html.EJ().DropDownListFor(model => model.select).Datasource((IEnumerable<CustomerList>)ViewBag.customerListDataSource).DropDownListFields(f => f.Text("Name").Value("value").ID("Id")).WatermarkText("Select").Width("400").ClientSideEvents(e => e.Select("onSelect")).ShowRoundedCorner(true).EnableAnimation(true)   
   
    <br>   
    @Html.EJ().DropDownListFor(model => model.select2).Datasource((IEnumerable<CustomerList>)ViewBag.customerListDataSource).DropDownListFields(f => f.Text("Name").Value("value").ID("Id")).WatermarkText("Select").Width("400").ClientSideEvents(e => e.Select("onSelect")).ShowRoundedCorner(true).EnableAnimation(true)   
    <input type="submit" value="Get" />   
    }   
</div>   
<script>   
    function onSelect(args)   
    {   
        if (this._id == "select") {   
            console.log("Selection in first dropdownlist");   
        }   
    }   
     
</script>   
   
   
After selecting the items in firs DropDownList, we get the corresponding selected values in id during form submit whereas the selected value of second dropdown is empty. Refer to the below screenshots.   
   
   
    
   
    
We have attached a sample based on this. Please download the sample from:   
   
   
   
If we have misunderstood, kindly modify the above sample to reproduce the issue along with product version details and replication procedure so that we can proceed further.   
   
Regards,   
Keerthana.   
  
 


Loader.
Up arrow icon