SuperDoc
SuperDoc

Reputation: 43

Check if DataRow contains something

I would like to check if my datarow contains a id and if yes do something. what I am doing: rrGneralRow is from type DataRow

if (rrGeneralRow.Equals(1057))
{
    if (!File.Exists(AtargetPath + checksourceFile))
    {
        File.Copy(AsourceFile, AtargetPath + Path.GetFileName(AsourceFile), overwrite: true);
    }
}
if (rrGeneralRow.Equals("1058"))
{
    if (!File.Exists(AtargetPath + checksourceFile))
    {
        File.Copy(AsourceFile, AtargetPath + Path.GetFileName(AsourceFile), overwrite: true);
    }
}

So I tried it with "" and without but both does not work. As you can see in my image the TREE_CATEGORY is existing and the number that I am looking for enter image description here

Upvotes: 0

Views: 1913

Answers (1)

mattygee
mattygee

Reputation: 147

rrGeneralRow appears to be a DataRow type. If this is the case, you need to interrogate the column name like so:

if (rrGeneralRow["TREE_CATEGORY"].ToString().Equals("1057")){

Upvotes: 1

Related Questions