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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:





130252 May 2,2017 11:00 AM May 3,2017 11:48 PM ASP.NET Core 3
Tags: DropDownList
Mark Chidlow
Asked On May 2, 2017 11:00 AM

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

Where is this documented please? 

Karthikeyan Viswanathan [Syncfusion]
Replied On May 3, 2017 06:55 AM

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. 

Mark Chidlow
Replied On May 3, 2017 10:08 AM

Many thanks Karthikeyan - great help!

Karthikeyan Viswanathan [Syncfusion]
Replied On May 3, 2017 11:48 PM

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. 


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.

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.