Radio Button on C#

Asked

Viewed 476 times

1

Hello, I have a registration screen and save everything ok according to the data filled, but when I click the change button returns all values entries, but does not return radio button selected as it was registered at the time of inclusion.

That is, when I click the change button and should return radio button selected c#.

How do I do?

if (CodTaxa > 0)
{
    objTaxa = TaxaBo.getByID(CodTaxa);
    objTaxa.DESCRICAO = txtEditDescricao.Text;
    objTaxa.TIPOVALOR = tipoValor.ToString(); //valor atribuido pelo radio button
    objTaxa.REC_DESP = operacao;//valor atribuido pelo radio button
    objTaxa.VLRPADRAO = Convert.ToDecimal(txtEditValorPadrao.Text);

    if(ValidaCampos())
    { 
        TaxaBo.Alterar(objTaxa);
    }
    else
    {
        MessageBox.Show("Algum campo precisa ser preenchido", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        return;
    }
}
  • Put the code of how you load the data on the screen because without the code is hard to know, it might be some component Binding error.

  • Other than Binding, you may not be assigning value to the Checked property.

  • already there!!!! There is some property or method to put as attribution in REC_DESP?

  • Where is the part of the code that you fill the components with the object information?

  • In order for your radio button to be marked as you said, the Checked property has to be set (receiving value: True or False in binary would be 0 or 1). In this code posted it is not clear where you are performing this operation.

1 answer

1

This way you will be able to validate and be able to display the information...

 //Radio Button Checked
        if (rbY.Checked)
        {
            Model.Tipo_Id = 1;
        }
        if (rbZ.Checked)
        {
            Model.Tipo_Id = 2;
        }

This Tipo_id is where the Radio options are saved

Browser other questions tagged

You are not signed in. Login or sign up in order to post.