How to filter data table based on string. Facing problem with datatype

Hello friends.
Im reading excel sheet where a column item_number is creating problem.

I have to filter datatable after reading excel. Problem is the column has numbers and also albhabets. Sometimes the numbers are in number format. When i search that number by my variable which is string type the search result gives no value.
Any solutions for this will help me a lot.

Thanks in advance

Hi,

How about using LINQ as the following?

arrDr = dt.AsEnumerable.Where(Function(r) r("ColumnName").ToString=yourString).ToArray()

Check if arrDr has datarow

Then

dtResult = arrDr.CopyToDataTable

note: arrDr is datarow array type

Regards,

1 Like

@aslam_ali1

Use linq filtering using assign

filtereddt = Dt.AsEnumerable.Where(function(x) x("ColumnName").ToString.Equals("RequiredValue"))

Cheers

1 Like

Thank you @Yoichi . It is working.

1 Like

Thank you @Anil_G for your quick reply.

1 Like

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