Click here to Skip to main content
15,896,464 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
In loop i get all rows of datagridview and get value one field with name Ststus. This fields contains string data "0" or "1"
When i do check:

C#
foreach (DataGridViewRow item in ListCards.Rows)
            {
                if (item.Cells["Status"].Value == "1")
                {


}

}


My condition if works always false even if at item.Cells["Status"] there is value = 1
What i do wrong?
Posted
Comments
Sergey Alexandrovich Kryukov 18-Apr-13 12:34pm    
Why having string data "0" or "1" ever? How about Boolean? (And a check box cell.)
—SA
[no name] 18-Apr-13 12:35pm    
I now made this construction:

string valus = item.Cells["Status"].ValueType.ToString();
if (valus == "1")

At valus i get type system.object.
José Amílcar Casimiro 18-Apr-13 12:49pm    
If you add a watch to this statement item.Cells["Status"].Value, what value do you get?

1 solution

C#
foreach (DataGridViewRow item in ListCards.Rows)
            {
                if (item.SelectedCells["Status"].Value.ToString() == "1")
                {
 

                 }
 
           }
 
Share this answer
 
v2

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