lundi 22 février 2021

How to check/uncheck value in a DataGridViewCheckBoxColumn when adding rows from database? c#

I have a DataGridView where I am adding values to from a Database select like so:

using (SqlDataReader Read = Com.ExecuteReader())
                {
                    while (Read.Read())
                    {
                        if(Read["VerificationStatus"].ToString() == "VERIFIED")
                        {
                            verify = "true";
                        } 
                        else
                        {
                            verify = "false";
                        }

                        if (Read["Penalty"].ToString() == "Y")
                        {
                            penalty = "true";
                        }
                        else
                        {
                            penalty = "false";
                        }

                        paymentsTbl.Rows.Add(Read["PaymentID"].ToString(), Read["PrimaryHolder"].ToString(), Read["CertificateNum"].ToString(), Read["IntStartDate"].ToString(), Read["IntEndDate"].ToString(),
                            Read["PaymentAmount"].ToString(), Read["RoundedInterest"].ToString(), verify, penalty, Read["PenaltyAmt"].ToString(), Read["TotalPaid"].ToString());

                    }
                }

However, where I am adding the "true" and "false" values it gives me an error whereby the value cannot be implicitly converted. Tried this with a bool value as well. What is the correct procedure for this?




Aucun commentaire:

Enregistrer un commentaire