0

I have two group boxes in which I have by 3 radio buttons and I want the selected value of the radio button to be inserted in the database.

I use this below code but its not working. Regarding the table, I have only one row for this value to be inserted

sqlDataAdapter1.InsertCommand.Parameters.Add("@n", SqlDbType.VarChar).Value = this.groupKamera.Checked.ToString();
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ardi
  • 11
  • 1
  • 6
  • Possible duplicate of [How do I get which radio button is checked from a groupbox?](https://stackoverflow.com/questions/18547326/how-do-i-get-which-radio-button-is-checked-from-a-groupbox) – Crowcoder Dec 09 '18 at 13:07

1 Answers1

-1

In case to save the radio button name

var selectedRadioButton = groupKamera.Controls
   .OfType<RadioButton>()
   .FirstOrDefault(t => t.Checked);

sqlDataAdapter1.InsertCommand.Parameters.Add("@n", SqlDbType.VarChar).Value = this.selectedRadioButton.ID;
Nomi Ali
  • 2,165
  • 3
  • 27
  • 48