Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new in C# windows application, could you help me to solve my problem? I'm trying to display the checkbox checked based on its value in the database.

I have two checkbox
1.fullpayment
2.EMI

when i retrieve data from database it's should automatically checked the checkbox.

if it is fullpayment then fullpayment checkbox should check, if EMI then emi checkbox should check.
Posted

I think this will solve your problem.
C#
If (fullpayment)//Check with your database value
chkFullpayment.checked=true;//set checkbox checked Property to true
else
chkFullpayment.checked=false;

if(EMI)//Check with your database value
chkEMI.checked=true;//set checkbox checked Property to true
else
chkEMI.checked=false;
 
Share this answer
 
C#
string PaymentType;
SqlConnection con=new SqlConnection(ConString);
SqlCommand cmd=new SqlCommand("SELECT PaymentType FROM TableName WHERE ID =1", con);
con.open();
PaymentType=cmd.ExecuteScalar().ToString();
if(PaymentType=="FullPayment")
{
     chkFullPayment.Checked=true;
}
else if(PaymentType=="EMI")
{
     chkEMI.Checked=true;
}
 
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