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.
James AxsomPosted Jul 30, 2018, 4:24 PM
State: No value selected from a drop down list
Result: No XYZ is saved
State: A value is selected from a drop down list
Result: XYZ is saved
Go to your save subroutine and see how you are handling the ado.net sql parameter value. Just because you disable a list box doesn't mean that something like an empty string or a null value is not being saved.
{
// add parameter to your sql command
}
// else don't add the parameter
Alex PPosted Jul 30, 2018, 12:39 PM
James AxsomPosted Jul 29, 2018, 8:15 PM
Hi Alex,