We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Dropdownlist in partial view only displaying first item

I have a partial view that opens as a modal. And I have a dropdownlist in the form beieng populated by ViewBag. It only display the first item in the dropdown though, There are 174 results in the ViewBag variable, but it only displays the first one.

Here is the code for the dropdown in the partial view:

                               <div class="e-float-input">
                                    @Html.EJS().DropDownList("AID").Placeholder("Select an Agency").PopupHeight("200px").Change("aidchange").DataSource((IEnumerable<object>)ViewBag.AgencyDD).Fields(df => df.Text("Agency").Value("ID")).Width("150px").Render()

                                    <span class="e-float-line"></span>
                                    <label class="e-float-text e-label-top" for="name">Agency</label>
                                </div>

I know that the ViewBag is getting to the partial in the modal, because of the first item, but why is the rest of the list missing.

Thanks for any help you can provide.

5 Replies

PO Prince Oliver Syncfusion Team June 3, 2019 12:22 PM UTC

Hello Adam, 

Good day to you. 

Based on the information that is shared. We suspect that the issue may have occurred at your end due to missing ScriptManager on your partial view page. We would suggest ensuring this at your end and adding the script manager to your end if it's missing. 

[Main view] 
<div class="col-lg-12 control-section" style="margin: 50px"> 
  <div id="wrapper"> 
  </div> 
</div> 
<button id="datebutton" text="Click" onclick="onClick()"> click Partial view </button> 
<script type="text/javascript"> 
  function onClick() { 
    var ajax = new ej.base.Ajax('/Home/PartialView1/?Person2', 'GET', true); 
    ajax.send().then(); 
    ajax.onSuccess = function (data) { 
      $("#wrapper").html(data); 
    } 
  } 
</script> 

[Partial view] 
@(Html.EJS().DropDownList("Album").DataSource((IEnumerable<object>)ViewBag.data) 
    .Placeholder("Selecciona").PopupHeight("200px").Render() 
) 
@Html.EJS().ScriptManager() 

We have attached a sample for your reference, please find the sample at the following location: http://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1-1985403812452125010 

Let us know if you need any further assistance on this. 

Regards, 
Prince 



AD Adam June 3, 2019 07:54 PM UTC

Prince,

Thanks for the reply. I tried adding the Script Manager as it was missing, but that did not fix the issue. I stumbled across the problem, it is the ".Change("aidchange") part of the Drop Down control. I remove it and it works. However I need to be able to call a javascript function for the selected item changing. Any idea why this would cause a problem?

Thanks,
Adam


VK Vinoth Kumar Sundara Moorthy Syncfusion Team June 4, 2019 10:47 AM UTC

Hi Adam, 
 
Good day to you. 
 
We suspect that you have triggered the change event after script manager has been loaded. You need to the change event function before the script manager. Please refer the sample below, 
 
 
Could you please check the above sample and get back to us if you need any further assistance on this? 
 
Regards, 
Vinoth kumar 



AD Adam June 4, 2019 03:44 PM UTC

Thank You, that seems to have the problem.


KR Karthik Ravichandran Syncfusion Team June 5, 2019 11:55 AM UTC

Hi Adam,

We are happy to hear that your issue has been resolved. Please let us know if you have any queries. 
  
Regards, 
Karthik R 


Loader.
Live Chat Icon For mobile
Up arrow icon