Wednesday 6 March 2013

how to copy a list into data table in c#.net and in linq

  DataTable dtnew = new DataTable();
                dtnew = dtPayment.Clone();
                dtnew.Rows.Clear();
                IEnumerable<DataRow> dtrows = (from f in dtPayment.AsEnumerable()
                                               where f["Amount"].ToString().Trim() != ""
                                               select f).ToArray();
                dtrows.CopyToDataTable(dtnew, System.Data.LoadOption.PreserveChanges);

No comments:

Post a Comment