How do i replace values in a column in the datatable?
I’ve the following which i got from another side, but it keeps returning me an error, about strict on disallowing implicit conversion from string to boolean…
dt = dt.AsEnumerable().Where(Function(a) a.Field(of string)(“yourcolumnname”).ToString.Replace(“your old value”,” your new value”).ToString).CopyToDatatable()
using the same replace linq, how do i replace empty value with something else?
like this? dt.AsEnumerable.ToList.ForEach(Function(row) If(IsNothing(row(colName).toString) OrElse String.IsNullOrWhiteSpace(row(colName).toString), "NULL", row(colName).toString))
Hi @Username95
You can skip the blank by adding the small code in @ppr response
yourDataTable.AsEnumerable().Where(Function(row) Not row(“ColNameOrIndex”).ToString.Equals(“”)).ToList.ForEach(Sub(row) row(“ColNameOrIndex”)= row(“ColNameOrIndex”).ToString.Replace(“your old value”,” your new value”))
Make sure the variable yourDataTable should be passed to invoke code with argument type as In/Out