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

Null value for empty entries in DropDown

Thread ID:





123326 Mar 8,2016 03:11 PM UTC Mar 10,2016 04:05 AM UTC ASP.NET MVC 3
Tags: Grid
Omar Muscatello
Asked On March 8, 2016 03:11 PM UTC

Hello Syncfusion Team,
I'm working with the Grid control.

The grid show a nested entity throught:

col.Field(x => x.Categoria.Id).HeaderText("Categoria")

I want to allow the user to set an empty value for this field. In the controller I added:

        public ActionResult Index()
            var categorie = new DataDbContext().Categorie.ToList();
            categorie.Add(new Categoria()); // Empty entry, Id = 0

            ViewBag.Categorie = categorie;
            return View();

In this way, it shows the empty entry.

In the controller, to save the changes I use:

        public JsonResult Modifica(PazienteViewModel.Index value)
            using (DataDbContext db = new DataDbContext(false))
                Paziente mPaziente = db.Pazienti.Find(value.Id);


                mPaziente.IdCategoria = value.Categoria?.Id == 0 ? null : value.Categoria?.Id; // When the user selects the empty entry, value.Categoria.Id = 0, so I have to check if 0 and replace with null. 


                return Json(true);

Is there any alternative for the code highlighted in yellow?

Balaji Marimuthu [Syncfusion]
Replied On March 9, 2016 02:16 PM UTC

Hi Omar,

Thanks for contacting Syncfusion support.

You have processed the correct way and it’s the best approach. So we suggest you to the same, and get back to us if you need any further assistance.

Balaji Marimuthu

Omar Muscatello
Replied On March 9, 2016 05:22 PM UTC

Ok, thank you Balaji Marimuthu.

Balaji Marimuthu [Syncfusion]
Replied On March 10, 2016 04:05 AM UTC

Hi Omar,

Thanks for the update.

Please get back to us if you need any further assistance.

Balaji Marimuthu


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