Guest User

Untitled

a guest
Apr 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. DataRow[] row = table.Select("Weight='57'");// has 1 record
  2. DataTable dt = new DataTable();
  3.  
  4. foreach (DataRow dr in row)
  5. {
  6. dt.ImportRow(dr);
  7. }
  8. dt.AcceptChanges();
  9.  
  10. DataTable dtDest = new DataTable();
  11. dtDest = dsActivity.Tables[0].Clone();
  12. foreach(DataRow dr in dsSrc.Tables[0].Rows)
  13. {
  14. DataRow newRow = dtDest .NewRow();
  15. newRow.ItemArray = dr.ItemArray;
  16. dtDest.Rows.Add(newRow);
  17. }
  18.  
  19. DataRow[] rows = table.Select("Weight='57'");
  20. DataTable dt = new DataTable();
  21.  
  22. foreach (DataRow item in rows)
  23. {
  24. // add values into the datatable
  25. dt.Rows.Add(item.ItemArray);
  26. }
  27.  
  28. dt.Rows.Add(dr)
  29.  
  30. DataTable DT = DTMain.Clone();
  31. // suppose DT is the table where we need to put datarows and DTMain is a table
  32. // having the stucture of the datatbale, means you must have some structure for
  33. // datatable.
  34.  
  35. //supposes you have a collection of datarows as
  36.  
  37. foreach(DataRow dr in DatarRowColl)
  38. {
  39. DT.ImportRow(dr);
  40. }
  41.  
  42. DT.AcceptChanges();
  43.  
  44. // here you get the datarows in a datatable.
  45.  
  46. DataTable dt = new DataTable();
  47.  
  48. DataRow[] dr = dt.Select("Your string");
  49.  
  50. DataTable dt1 = dr.copyToDataTable();
Add Comment
Please, Sign In to add comment