In my Add Data Row activity I am using the following for my ArrayRow

{item("ref").ToString,Convert.ToString(GID_LimitedData.Rows(ICS_RowIndex)(2)),Convert.ToString(GID_LimitedData.Rows(ICS_RowIndex)(3)),item("price").ToString}

My problem is that sometimes item("ref").ToString will not exist and sometimes it will.

Currently the error I get when it does not exist is:

Add Data Row: Element 'price' not found.

I would be interested in workaround or also best practices for this situation. Thanks for the help

1

Best Answer


You could just use the following in place of item("ref").ToString

If(String.IsNullOrEmpty(item("ref").ToString), String.Empty, item("ref").ToString)

This will execute an If, and where the first clause is true, report the String.Empty into the ArrayRow, and item("ref").ToString where it's not.

If you're not so comfortable with that, assign the various values to meaningful variables in advance of the Add Data Row activity and use the variables in the activity instead. That will let you handle any missing values before you try to add them to the target datatable