-1
How could I validate the fields below so they don’t go blank, because my biggest difficulty is that two of them have Convert.
NegocioFuncionario neg = new NegocioFuncionario();
EntidadeFuncionario ent = new EntidadeFuncionario();
ent.Matricula = Convert.ToInt32(txtMatricula.Text);
ent.DataNascimento = Convert.ToDateTime(txtNascimento.Text);
ent.Nome = txtNome.Text;
ent.Situacao = cboSituacao.SelectedItem.ToString();
Tag the language you are using.
– Wictor Chaves
I don’t know which link you’re using, but I believe a simple if will solve your problem, e.g.: if(txtMatricula.Text == "" || txtMatricula.Text == null){ Return false; }
– Wictor Chaves
I believe you are working with C#, if you are, you can do it this way: if (txtMatricula.Text == string.Empty){ Return false; }
– Wictor Chaves
I’m using the C# anyway. However, when including this command always gives this error message "System.Formatexception: 'Input string was not in a correct format", because it txtMatricula field is being converted to string at first.
– Rafael Ventura
But at what point you entered the command
if
?? It would have to be before the conversion, then you won’t have a problem.– Andrey
This, before the conversion, I created a response with the code.
– Wictor Chaves
You’re a genius, Wictor. My problem has been solved with something very simple and practical. Thanks a lot!
– Rafael Ventura