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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drop Down List

Thread ID:





131902 Aug 2,2017 11:16 AM UTC Aug 3,2017 05:48 PM UTC ASP.NET Core 1
Tags: Grid
Edmund Herbert
Asked On August 2, 2017 11:16 AM UTC

Hi Support

Could you show me how to populate Drop down List in a Grid field using a table from EF


Edmund Herbert

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On August 3, 2017 05:48 PM UTC

Hi Edmund, 

Thanks for contacting Syncfusion Support. 

We have created sample with Entity framework by creating the db NorthWNDContext_context and bind to the Grid datasource. Also we have bind the Employee db to the dropdown datasource of the Grid column.Please refer to the code example:- 

<ej-grid id="Grid" allow-paging="true" allow-sorting="true" action-complete="onComplete"> 
      <e-datamanager json="(IEnumerable<Orders>)ViewBag.datasource" remove-url="Home/Delete" update-url="Home/Update" insert-url="Home/Insert" adaptor="remoteSaveAdaptor"></e-datamanager> 
                <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" ></e-edit-settings> 
                    <e-column field="OrderID" is-primary-key="true" header-text="Order ID" text-align="Right"></e-column> 
                    <e-column field="CustomerID" header-text="CustomerID" edit-type="String"></e-column> 
                    <e-column field="ShipCity" header-text="Ship City datasource="(IEnumerable<Employee>)ViewBag.datasource"  edit-type="Dropdown"></e-column> 


public class HomeController : Controller 
        private NORTHWNDContext _context; 
        public HomeController(NORTHWNDContext context) 
            _context = context; 
        public IActionResult Index() 
            List<Orders>  Result = _context.Orders.Take(100).ToList(); 
            ViewBag.datasource = Result; 
                            List<Employee> data = new List<Employee>(); 
            data = db.Employees.ToList(); 
            ViewBag.DataSource = data; 
            return View(); 
        public List<Orders> GetData() 
            List<Orders> datas = _context.Orders.Take(100).ToList(); 
            return datas; 
      public ActionResult Data([FromBody]DataManager dm) 
            IEnumerable Data = _context.Orders.Take(100).ToList(); 
            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations(); 
            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting 
                Data = operation.PerformSorting(Data, dm.Sorted); 
            if (dm.Where != null && dm.Where.Count > 0) //Filtering 
                Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator); 
            if (dm.Search != null && dm.Search.Count > 0) //searching 
                Data = operation.PerformSearching(Data, dm.Search); 
            int count = Data.AsQueryable().Count(); 
            if (dm.Skip != 0) 
                Data = operation.PerformSkip(Data, dm.Skip); 
            if (dm.Take != 0) 
                Data = operation.PerformTake(Data, dm.Take); 
            return Json(new { result = Data, count = count }); 
        public class DataResult 
            public IEnumerable result { get; set; } 
            public int count { get; set; } 
            public IEnumerable aggregate { get; set; } 
            public IEnumerable groupDs { get; set; } 
        public ActionResult CellEditInsert([FromBody]EditParams value) 
            var datas = _context; 
            return Json(value); 
        public ActionResult CellEditUpdate([FromBody]EditParams value) 
            var db = _context; 
            db.Entry(value.value).State = EntityState.Modified; 
            return Json(value); 
        public ActionResult CellEditDelete([FromBody]EditParams value) 
            var db = _context; 
            Orders order = db.Orders.Where(c => c.OrderID == Convert.ToInt32(value.key)).FirstOrDefault(); 
            return Json(order); 

Please refer to the sample and documentation link :- 


Farveen sulthana T 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon