Alex P

Alex P

  • NA
  • 16
  • 898

Disable a default value from dropdownlist

Jul 29 2018 2:23 PM
Hi, I have a code where it takes and saves input as XYZ if no value is selected from a drop down list. I want to disable it, so that the system is not allowed to save any empty value.
 
As a trial & error method I just uncommented a piece of code.
 
//var defaultSelectItem = new SelectListItem() { Text = "-SELECT ONE-", Value = "XYZ", Selected = String.IsNullOrEmpty(jurisCode) };
//jurisForDisplay.Insert(0, defaultSelectItem);
 
Result: It doesn't give me a  option to leave blank.
Partial problem: System itself gives a state name as a default input in alphabetic order. So, the user should be cautious to edit the state name. Which is tough in my case as end users are truck drivers.
 
Is there something else I can do which allows user to select input by himself and should also not allow a blank valur to be saved. 

Answers (3)