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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dropdownlist in partial view only displaying first item

Thread ID:

Created:

Updated:

Platform:

Replies:

145019 Jun 2,2019 12:46 AM UTC Jun 5,2019 11:55 AM UTC ASP.NET MVC - EJ 2 5
loading
Tags: DropDownList
Adam
Asked On June 2, 2019 12:46 AM UTC

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.

Prince Oliver [Syncfusion]
Replied On 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 


Adam
Replied On 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

Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On 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 


Adam
Replied On June 4, 2019 03:44 PM UTC

Thank You, that seems to have the problem.

Karthik Ravichandran [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon