@{
var select = new SelectList((IEnumerable<Dictionary>)ViewData["Regions"], "ID","Title");
}
@(Html.EJ().DropDownList("DDL")
.Datasource(select.Items)
.DropDownListFields(f => f.Text(select.DataTextField)).Value(select.DataValueField)
.WatermarkText("Select")
) |
Hi John,Thanks for contacting Syncfusion support.From the code, you shared, we tried to reconstruct your scenario. In that SelectList class returns a list of properties as given in the below MSDN link:Datasource property in our Dropdownlist cannot directly access the items property of the Selectlist constructor. Hence we need to map the Selectlist properties to the respective dropdownlist’s properties. Please look at the following code snippet.
@{var select = new SelectList((IEnumerable<Dictionary>)ViewData["Regions"], "ID","Title");}@(Html.EJ().DropDownList("DDL").Datasource(select.Items).DropDownListFields(f => f.Text(select.DataTextField)).Value(select.DataValueField).WatermarkText("Select"))We have attached a sample for your convenience, refer to the following for a sample:Regards,Prince
<h2>Dropdown1</h2>
@(Html.EJ().DropDownList("DDL")
.Datasource(newSelectList((IEnumerable<Dictionary>)ViewData["Regions"], "ID", "Title").Items)
.DropDownListFields(f => f.Text("Title")).Value("ID")
.WatermarkText("Select")
)
<h2>Dropdown2</h2>
@(Html.EJ().DropDownList("DDL2")
.Datasource((IEnumerable<Dictionary>)ViewData["Regions"])
.DropDownListFields(f => f.Text("Title")).Value("ID")
.WatermarkText("Select")
) |