I declared a list variable and then use linq query to filter the data table. but when ever the condition does not satisy it returns empty or null value and throws error. What is the workaround to avoid this condition?
Assign: Value cannot be null. (Parameter ‘source’)
Use if condition and check if filtered data Row Count > 0, if yes then assign else you can clone the datatable to return empty values
e.g.
If(YourDT.AsEnumerable().Where(Function(row) row(“Col1”).ToString.Equals(“Value”)).Count>0,YourDT.AsEnumerable().Where(Function(row) row(“Col1”).ToString.Equals(“Value”)).CopytoDataTable,YourDT.Clone)
If list is returning a valid object i can use above code , but here list itself null so i cannot chain the count function. Once it goes to else block ot throws same error