Hello, I need help to render the selected item in the dropdownlist using templated html
below is my code for the dropdown component
@Html.EJS().DropDownList("CSTNameUpdate").DataSource(ds => ds.Url(@Url.Action("DropDownListCSTName", "EngineeringEquipment"))).Placeholder("Select CST").Fields(new Syncfusion.EJ2.DropDowns.DropDownListFieldSettings { Value = "Key" }).ItemTemplate(
"<div style=\"margin-top:3px\" >${Key}-${COLUMN_NAME}</div>").ActionFailure("onCSTFail").ValueTemplate(
"<div style=\"width:100%;height:100%;\"><div class=\"name\">${Key}-${COLUMN_NAME}</div></div>").Change("CSTNameOnChangeUpdate").FloatLabelType(Syncfusion.EJ2.Inputs.FloatLabelType.Always).Render()
AND THIS IS my datasource:
I cannot seem to find the solution, thankyou
Hi Bernadus,
As per requirement we have created a sample using an item template and value template and shared the sample link below for your reference. Please refer to the below documentation and the online demo sample for more information.
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/MVC_DDL_URL_sample-552102750
Documentation : https://ej2.syncfusion.com/aspnetmvc/documentation/drop-down-list/templates
Online Demo : https://ej2.syncfusion.com/aspnetmvc/DropDownList/Template#/bootstrap5
Regards,
Udhaya Kumar D
I think this sample is not what I asked for.
I need the drop downlist value option is already choosen based on Model...
so its like edit form, the drop down should be already selected and so, user know what the selected value before he/she want to change it.. Thanks
Hi Bernadus,
We suggest you use for components when initializing the component with model value and validate like edit form components.
To know more about the for component. Please refer to the online demo here: https://ej2.syncfusion.com/aspnetmvc/DropDownList/DropdownlistFor#/bootstrap5
Regards,
Sureshkumar P
thankyouu
Hi Bernadus,
Hope that the previously provided solution fulfills your requirement . Kindly contact us if need more assistance on this.
Thanks,
Deepak R.