I have columns in my datatable with 10,000 rows. I would like to change the values of a column
called “Standard” which is “X” (a string) to int32 value i.e. 1. I tried below Linq query but it is giving error “Option strict on disallows implicit conversion from “string” to “boolean””.
(From d In In_DT.AsEnumerable()
Let r1 = d.ItemArray.Select(Function (x) x.toString.Replace(“X”, ”1”)).toArray
Select r2 =Out_DT.Rows.Add(r1)).CopyToDataTable
Thanks for replying. First, the clone method is only copying the structure(i.e. names of column). I used dt.copy afterwards, so that it copies all the column values. Now your query seems to replace “X” with 1 but the problem is, it is updating values in first column not under “Standard” column and all the other column’s value are gone as well. I need complete datatable with only X values replaced by 1. Here is the output:
@prasath17 I tried your solution and it’s working. Thanks for your effort. I would also like to replace empty cells with “0”. In my case, the data type of standard column is object. I tried your query for example: