How to make a label receive a text from the database

Asked

Viewed 759 times

1

Hello I know the question is very simple, but I’m having a difficulty, I have a radio button and I would like his text to be received from an SQL Server database through a SELECT. I’m using the Entity Framework. Please leave examples.

  • 1

    How his text is saved in the bank?

  • Cara is a quiz that I am developing, I have a field in the bank with the name of "Questionaum" and I would like the text of this radiobuton to be filled by this field

  • Radio’s value would not be the answer?

1 answer

0


You can use the Checked property to set the value of your radiobutton, but you need to know what kind of data is coming from your bank.

The Checked property expects a boolean as value, so if you are storing a string(varchar) in your database, you can convert the string as follows.

radioButton1.Checked = Convert.ToBoolean(dt.Rows["PerguntaUM"]);

as long as its value is already Yes or False.

In the case of text you just need to use the property Text.

radioButton1.Text = dt.Rows["PerguntaUM"].ToString();

Browser other questions tagged

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