Hot to copy values from Datatable column in to existing List

Hi, i was lookig for some help with copying values for a datatable column in to an existing list. When i try the following it just overwrites the values in the list ( From row in dt.AsEnumerable() Select Convert.Tostring(row(“ColumnName”)) ) .ToList.Copy

How can i simply append without using a loop?

Thanks

dtList = dt.AsEnumerable().Select(Function (x) x("ColumnName").toString.Trim).toList
newList = oldList.Concat(dtList).toList

Also have a look here:

1 Like

@ppr [quote=“ppr, post:2, topic:537242”]

dt.AsEnumerable().Select(Function (x) row("ColumnName").toString.Trim).toList
newList = oldList.Concat(dtList).toList

[/quote]

Thank you for your quick reply. when i try to use, i recieve the error ‘row is not declared’. Could you help please?

Hi @qwerty1 ,

In addition to @ppr method, you can also use invoke method to add to the list as shown below using the AddRange function:

Pass your expression in the parameters.

Regards,

1 Like

did correct the statement in origin post above

1 Like

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