View Full Version : سوال: ارور String was not recognized as a valid Boolean
afshin_zeinal
دوشنبه 06 آبان 1392, 21:31 عصر
سلام من قصد دارم اطلاعات ستون هفتم اگر برابر no بود رنگ آن عوض شود که به این ارور برخوردم
لطقا راهنمایی کنید .
if (Convert.ToBoolean(DataGridView1.Rows[i].Cells[7].Value) == Convert.ToBoolean ( Convert.ToString( "No")))
esafb52
دوشنبه 06 آبان 1392, 22:00 عصر
شما به این روش نمیتونی از مقادیر منطقی استفاده کنی دوست عزیز
Convert.ToString( "No")
یه شرط بذار و مقدارش رو بخون اگر NO بود مثلا صفر و اگر YES بود مقدار یک
یا
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[7].Value=="no")
{
//statemnt
}
}
afshin_zeinal
دوشنبه 06 آبان 1392, 22:31 عصر
شما به این روش نمیتونی از مقادیر منطقی استفاده کنی دوست عزیز
Convert.ToString( "No")
یه شرط بذار و مقدارش رو بخون اگر NO بود مثلا صفر و اگر YES بود مقدار یک
یا
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Cells[7].Value=="no")
{
//statemnt
}
}
ارور زیر را می دهد
Possible unintended reference comparison; to get a value comparison, cast the left hand ide type 'string'
esafb52
دوشنبه 06 آبان 1392, 22:34 عصر
if (dataGridView1.Rows[i].Cells[7].Value.ToString() == "no")
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.