How to get datatable column dynamically


#1

Hi,
I need to refer datatable column dynamically in linq
eg datatable
S.No Name
1 Anu
2. Priya

I am using linq query to fetch the 2nd column name…I should not directly use "Name. Instead i want to use index or some ref

DT_table.Select("[Column B]=’" + Name.ToString + “’”). Tried this, not working


#2

Hi @DeviE,

Try this one
dataTable.Select("[" + dataTable.Columns[1].ColumnName + "] = '"+Name.ToString()+"'")

Regards,
Arivu