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

How to set the selected item of a DropDownList server-side?

How do I set the selected item of the DDL server side? Thanks.

Where is this documented please? 

3 Replies

KV Karthikeyan Viswanathan Syncfusion Team May 3, 2017 10:55 AM UTC

Hi Mark,  
Thanks for contacting Syncfusion support. 
You can set a selected item value using model binding in DropdownlistFor control.  Please refer to the code snippet: 
@using (Html.BeginForm()) 
    Html.EJ().DropDownListFor(model => model.bikeValue, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).WatermarkText("Select a car").Width("100%").Render(); 
        public IActionResult Index(BikeModel model) 
            DropDownListProperties ddl = new DropDownListProperties(); 
            ddl.DataSource = GetDataSource(); 
            DropDownListFields ddf = new DropDownListFields(); 
            ddf.Text = "text"; 
            ddf.Id = "empid"; 
            ddl.DropDownListFields = ddf; 
            model.bikeValue = "Pulsar"; 
            ViewData["ddl"] = ddl; 
            return View(model); 

Karthikeyan V. 

MC Mark Chidlow May 3, 2017 02:08 PM UTC

Many thanks Karthikeyan - great help!

KV Karthikeyan Viswanathan Syncfusion Team May 4, 2017 03:48 AM UTC

Hi Mark,   
Thanks for the update.  
We are glad the suggestion helped you to achieve your requirement.  
Please let us know if you need further assistance.  
Karthikeyan V. 

Live Chat Icon For mobile
Up arrow icon