Skip Empty Row in DataTable


I Have this scenario. I have DT, and I want to convert the value on the specific column from string to Decimal. it’s working fine if all the row is not empty, but it went to error when some row is empty.
I’m using invoke code to convert the row
dt.asenumerable.tolist.foreach(sub(row) row(Col)= CDec(row(Col)))



before invoke code could you add a condition if isnullorempty?

Can we have if statement inside the code, the thing is I’m not using for each row before invoke code

yes you can assgia the row value to a variable can check it is null, then choose to by pass it

Hi @rangga.waskita

Please try this,

dt.asenumerable.Where(function(row) not String.IsNullOrEmpty(row(Col).ToString)).tolist.foreach(sub(row) row(Col)= CDec(row(Col)))


Hi @prasath_S ,

Still error for the code

@rangga.waskita Updated the code , please try that.


It’s working perfectly, thanks @prasath_S :love_you_gesture:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.