How to update cell based on certain condition in datatable using Linq


I want to write LINQ to update the cell based on certain conditions.

Hi @Pooja2

Could you elaborate a requirement by providing the sample input or input and Output screenshots


I have column1,Column2,Column3,column4.

I am checking the value in column1 and column2 if it matches then I want to update that column3 and column4 values to empty

Hi @Pooja2

Refer to the thread


Hi @Pooja2

check with the below LINQ expression!

DtClone= readDt.Clone

(From d In readDt.AsEnumerable
Let u =If(d(0).toString.equals(d(1).toString),“Empty”,d(3).ToString)
Let r=If(d(0).toString.equals(d(1).toString),“Empty”,d(4).ToString)
Select DtClone.Rows.Add(New Object(){d(0),d(1),u,r})).CopyToDataTable

Where ReadDt is the readRangeDt


Hi pravin if possible can yu please explain morre line by line on how ur linq works ,

thank youu