开发者

Help! Checking if a field is empty

I'm using Linq开发者_如何学Python-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;
    }


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜