Even though several people have asked this question before non of those solved my problem. I have a database connection, through that i am adding and retrieving to/from database. But when I read from the database I need to make the RadioButtonList to be ticked. when I debug the code the if condition is getting triggered and the correct values are retrieved but it just exits from the condition and runs the next line.
I have tried removing the while (reader.Read()) loop and changed it as reader.read(). even then the same issue occurred. I've also tried this and nothing worked!
following is my code segment
while (reader.Read())
{
if (reader.IsDBNull(0))
{
}
else
{
result = reader["Type"].ToString();
if (result.Equals("X"))
{
RadioButtonList1.SelectedValue = "X";
}
else if (result == "Y")
{
RadioButtonList1.SelectedValue = "Y";
}
question_Tb.Text = (reader["Question"].ToString());
answer_One_Tb.Text = (reader["answer_One"].ToString());
answer_Two_Tb.Text = (reader["answer_Two"].ToString());
answer_Three_Tb.Text = (reader["answer_Three"].ToString());
}
}
I need the radio buttons to be ticked according to the value on the database while reading from database.
Aucun commentaire:
Enregistrer un commentaire