c# - Get radio button value -


I have tried to get the radio button value from the windows store application form, but the errors shown here are as follows, And im using Visual Studio 2013 and XML.

  Private Zero addButton_Click (Object Sender, RoutedEventArgs E) {try {string gender = null; If (malereadbutton ISI has been checked) (MadRDO button has been checked) {gender = Narroday button. Checked? "Male females"; } Entering into string query = @ "` bcasdb` .`tbl_student` (`reg_id`,` std_fname`, `std_lname`,` tbl_batch_batch_id`, `gender`) values ​​(@regId, @fName, @lName, @bID, @gender) "; // This is the command class which will handle the query and the connection object. MySqlConnection conn = New MySqlConnection (BCASApp.DataModel.DB_CON.connection); MySqlCommand CMD = New MySqlCommand (query, conn); Conn.Open (); Cmd.Parameters.AddWithValue ("@ regId", this.regIDInput.Text); Cmd.Parameters.AddWithValue ("@FName", this.fnameInput.Text); Cmd.Parameters.AddWithValue ("@ lName", this.lnameInput.Text); Cmd.Parameters.AddWithValue ("@ BID", this.batchIDInput.Text); Cmd.Parameters.AddWithValue ("@Gender", this.maleRadioButton); Cmd.ExecuteNonQuery (); Conn.Close (); SuccessmsgBox (); } Hold (exception) {errormsgBox (); }}   

There are errors in this section

  string gender = faucet; If (malereadbutton ISI has been checked) (MadRDO button has been checked) {gender = Narroday button. Checked? "Male females"; }    

property is not RadioButton.IsChecked [bool], its type [bool? ].

If you can not use just the sentence then

You can set specific Boolean variables to check the flags of radiobutton.

  bool isMale = false; Bool isFemale = false;   

And then,

  Private Zero RadioButton_Checked (Object Sender, RoutedEventArgs e) {isMale = this == maleRadioButton; IsFemale = Sender == Mother Radio button; }   

Of course, the maleRadioButton and femaleRadioButton event handler have been checked. Like,

  & lt; Radio button x: name = "normal button" checked = "radiobutton_hecked" /> & Lt; Radio button x: name = "MadRDObutton" checked = "RadioButton is hacked" />   

Then, you can use it as follow.

  string gender = null; If (IsMale || isFemale) {gender = Mail? "Male females"; }    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -