Hi Nitin,
Greetings from Syncfusion support
We have validated your query “Default Value for Dropdown”
Your requirement to set the default value for the DropDown list can be achieved by using the Index or Value property of DropDown list. Please check the below code,
Code snippet:
Index.cshtml
|
<div>
<ejs-dropdownlist id="games" value="@ViewBag.Value" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px">
</ejs-dropdownlist>
</div>
<div>
<ejs-dropdownlist id="games1" index="1" dataSource="@ViewBag.data" placeholder="games" popupHeight="220px">
</ejs-dropdownlist>
</div> |
HomeController.cs
|
public ActionResult Index()
{
ViewBag.data = new string[] { "Badminton", "Basketball", "Cricket", "Football", "Golf", "Gymnastics", "Hockey", "Tennis" };
ViewBag.Value = "Cricket";
return View();
} |
Please check the above sample and code snippet and let us know if it satisfies your requirement.
Regards,
Vinitha