Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sorry to be so new to this, but I am and I have figured out how to save my form entries to the database however now I want them to display on an edit page so the values can be updated. I am working with C# and I am using a stored procedure to pull the data out from the database and surface it for the form. I have tried the following to get a true/false radio button to display as what the value is in the DB which is true and the stored procedure pulls it back as 1.

What I have tried:

<pre>if (chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "true") 
                        {
                            chkAllRadioButton.Checked = true;
                        }

//and I have tried

if (chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "1") 
                        {
                            chkAllRadioButton.Checked = true;
                        }
Posted
Updated 14-Sep-17 18:01pm
Comments
A_Griffin 14-Sep-17 15:15pm    
Why are you checking for chkAllRadioButton.Checked as a condition when it is that which you are wanting to set?
chkAllRadioButton.Checked = [CBool](Details.chkAllRadioButton.ToString() = "true")
csteacy01 15-Sep-17 11:39am    
Ugg, tried both solutions with either of it working. To be honest, i'm doing it this way because this is how the other checkboxes are done and they work so i'm just trying to replicate.

1 solution

this will do the job if your stored procedure returns "1"
chkAllRadioButton.Checked = Details.chkAllRadioButton.ToString() == "1";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900