Category Archives: Data Table

Creating generic method or extension for searching through all the columns in DataTable in C#

Few days ago I worked on a project where database table has more than 80 columns. My client asked to create a search so that it can search through all the columns. So I have decided to create an extension method which will search through all the columns in DataTable. Creating generic method or extension read more »

Select Distinct Record from DataTable

If it is necessary to select distinct record from Data Table, then we can use following method. public DataTable SelectDistinct(DataTable SourceTable, string FieldName) { DataTable dt = new DataTable(); dt = SourceTable.Clone(); object LastValue = null; foreach (DataRow dr in SourceTable.Select(“”, FieldName)) { if (LastValue == null || !(ColumnEqual(LastValue, dr[FieldName]))) { LastValue = dr[FieldName]; dt.ImportRow(dr); read more »

Page 1 of 11