Jyoti Jodha

Jyoti Jodha

  • NA
  • 1.7k
  • 36.7k

How to retrieve data from database to radio button

Nov 17 2017 1:28 AM
How to retrieve data from database to radiobutton in Windows Form C#
 
 
I saved radiobutton value in database like "A4Size" or "A5Size".Now i want to retrieve that data from database to radiobutton.If A4Size in database i want to check the Radionbutton (A4Size) value other wise uncheck the radiobutton (A5Size) value.
Code Like this
private void BillLoad()
{
DataTable dt = new DataTable();
con.Open();
SqlDataReader myReader = null;
SqlCommand myCommand = new SqlCommand("select * from Bill ", con);
myReader = myCommand.ExecuteReader();
while (myReader.Read())
{
if (myReader["ReportSize"].ToString() == "A4_Size")
{
ChhkA4.Checked = true;
}
else
{
ChhkA5.Checked = true;
}
}
con.Close();
}
 
 

Answers (5)