Posted By

krisdb on 10/06/08


Tagged

c-sharp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Datatable/Dataview stuff


 / Published in: C#
 

  1. DataView dvName = dtName.DefaultView;
  2. dvName.Sort = "Column ASC";
  3.  
  4. foreach (DataRowView drv in dvName)
  5. {
  6. drv["Column"]
  7. }
  8.  
  9.  
  10. DataTable dtTable = new DataTable();
  11. foreach (DataRow dr in dtTable)
  12. {
  13. dr["Column"]
  14. }
  15.  
  16.  
  17.  
  18. DataTable dtName = new DataTable();
  19.  
  20. DataView dvName = dtName.DefaultView;
  21. dvName.RowFilter = "ID = " + intID
  22. dvName.Sort = "Date DESC";
  23.  
  24. DataTable dtResults = new DataTable();
  25. dtResults.Columns.Add(new DataColumn("ID", System.Type.GetType("System.String")));
  26. dtResults.Columns.Add(new DataColumn("Title", System.Type.GetType("System.String")));
  27. dtResults.Columns.Add(new DataColumn("Date", System.Type.GetType("System.DateTime")));
  28.  
  29. DataRow drResults = dtResults.NewRow();
  30.  
  31. drResults["ID"] = id;
  32. drResults["Title"] = title;
  33. drResults["Date"] = Convert.ToDateTime(date);
  34.  
  35. dtResults.Rows.Add(drResults);

Report this snippet  

You need to login to post a comment.