Q:

comparing datarow value with a string in if

I have an application which stores a user selected value to the value in my dataset filled datatable. I need to set another column in the table based on this comparison. But the comparison is not working. It always returns false, not entering in the if condition.
foreach (DataRow dr in dsQuestions.Tables[0].Rows)
{
    if (dr["Data"] == indicater[0])
    {
        dr["IsSelected"] = true;
    }
}

indiactor[0] is a string array and dr["data"] is also of type string but it shows a warning that it needs to a string type.

A:

The DataRow indexer returns the field at that index as object not as string.
I would recommend to use the strongly typed Field-extension method which also supports nullables:
if (dr.Field<String>("Data") == indicater[0]){}

... and the SetField method that also support nullable types:
dr.SetField("IsSelected", true);

Update if indicater[0] is really a string[] (not a single string), how do you want to compare a string with a string[]? If you for example want to check if the array contains this data:
if (indicater[0].Contains(dr.Field<String>("Data"))){}

That would also explain why it never enters the if: because == only compares strings by equality, other types which don't have overridden the ==-operator will compare only the reference. A string is never the same reference as a string[]. But you don't get a compile time error because you can compare an object with everything else.

A:

First of all string can't compare using == you should use equals method:
foreach (DataRow dr in dsQuestions.Tables[0].Rows)
            {
               if (dr["Data"].tostring().Equals(indicater[0]))
                {
                    dr["IsSelected"] = true;
               }

