tags:

views:

58

answers:

1

I'm using Linq-to-SQL as my ORM on a ASP.Net MVC2 application. I have a table called Area which is related to the Jefe table.

In my application, I don't want users to write down a value in the IDJefe field, but rather select from a combobox.

Should I ask if string.NullorEmpty for (IDJefe) or (Jefe)? Both of these properties are available to me, but this is my first adventure into building a full application with Linq-to-SQL.

I was thinking of using IDJefe as the value to check, because a comboBox can have a selectedIndex, right?

Thank you.

public IEnumerable<RuleViolation> GetRuleViolations()
    {
        if (String.IsNullOrEmpty(Nombre))
            yield return new RuleViolation("Nombre requerido", "Nombre");

        if (IDJefe == null)
            yield return new RuleViolation("Jefe requerido", "IDJefe");

        yield break;
    }
A: 

You should check against the combobox selected value if selecting an IDJefe value is necessary.

For more info on validating it:

How to validate that a dropdown list item has been selected

Leniel Macaferi