David Smith

David Smith

  • NA
  • 2k
  • 0

Common Reuse Datatable Extension Methods

Nov 25 2014 10:52 AM

Can someone point me to a good site that has common reuse datatable extension for things like update, add, modify, delete and so forth. I am trying to build an common extension class. Give you example below of an reuse function I created below. Are there anymore you can think of?

public static DataTable Filter(this DataTable dt, string filter)
{
dt.DefaultView.RowFilter = filter;
return dt.DefaultView.ToTable();
}

public static DataTable AddRow(this DataTable datatable, string columnName, object value)
{
DataRow newDataRow = datatable.NewRow();

newDataRow[columnName] = value;

datatable.Rows.Add(newDataRow);

return datatable;
}