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 doesn't work with list in form

I have a form which consists a list of dropdown boxes, the code below using <select> works, but when I try to use DropDownList, it doesn't render properly.

<form asp-action="Confirm">
    <div class="form-horizontal">
        <div asp-validation-summary="ModelOnly" class="text-danger"></div>
        <input type="hidden" asp-for="BlobName" />
        <table class="table">
            <thead>
                <tr>
                    <th>
                        Unknown Contacts
                    </th>
                    <th>
                        Solution
                    </th>
                </tr>
            </thead>
            <tbody>
                @for (int i=0; i < Model.ContactConfirmation.Count;i++)
                {
                    <tr>
                        <td>
                        <input type="text" name="confirmation.ContactConfirmation[@i].UnmatchContactName" asp-for="@Model.ContactConfirmation[i].UnmatchContactName" class="form-control" readonly />
                        </td>
                        <td>
                            <select name="confirmation.ContactConfirmation[@i].NewContactName" asp-for="@Model.ContactConfirmation[i].NewContactName" asp-items="@ViewBag.contacts"></select>   
                        </td>
                    </tr>
                }
            </tbody>
        </table>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Confirm" class="btn btn-default" />
            </div>
        </div>
    </div>
</form>

1 Reply

KR Keerthana Rajendran Syncfusion Team June 29, 2017 12:17 PM UTC

Hi Zhen, 
 
Thank you for contacting  Syncfusion support . 
 
We have prepared a sample based on your code and rendered our ejDropDownList inside for loop. Please refer the below given code 
 
<tbody> 
                @for (int i = 0; i < Model.band.Count; i++) 
                { 
                    
                    <tr> 
                        <td> 
                            @{Html.EJ().DropDownListFor(model=>model.band[i].display,(Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).Width("100%").Render();} 
 
                        </td> 
                    </tr> 
               } 
 
 
            </tbody> 
 
 
We have attached sample for your reference. Kindly refer to the below given link 
 
 
 
Regards, 
Keerthana. 


Loader.
Live Chat Icon For mobile
Up arrow icon