The property
Text
is never null. It could be empty, could contain only blank spaces, and so on. If you need to test if some entered data is empty, you can do this
if (txtNvSt.Text == string.Empty)
or
if (string.IsNullOrEmpty(txtNvSt.Text))
Also, you may want to consider something like
if (txtNvSt.Text.Trim() != string.Empty)
The first and last fragment essentially based on assumption that
txtNvSt.Text
is never null. In other cases where null is possible you should also check for null.
To see what part of your code is
really executed, in case of even slightest doubt, always use the debugger. It will also tell you which part of
condition is true or false. :-)
—SA