Filter a datatable when the column also needs to be converted


#1

I have a datatable with 4 columns built using data scraping, so all the columns are text. I need to filter the datatable based on one of the columns, but as an integer. Criteria similar to Col1 > 10 AND < 100.

I have searched the forum and can’t seem to find an example with data conversion and the Select statement on a datatable.


#2

@Kristian_Jackson

Let us take you are having a datatable dta

Then Filtered dataRow Array as drabc

drabc = (From row in dta.Select
         where Convert.ToInt32(row("Column_Name" or Column_Index).ToString)>10 and 
         Convert.ToInt32(row("Column_Name" or Column_Index).ToString)<100
         Select row).ToArray

If drabc.count>0

dtb= drabc.CopyToDataTable()

dtb is the Filtered DataTable.

Regards,
Mahesh


#3

@Kristian_Jackson Try below code. Output of below code is dataTable

datatableVariable.Select("[ColumnName]>10 and [ColumnName]<100").CopyToDataTable