Advertisement
Guest User

Untitled

a guest
Apr 28th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. static DataTable ConvertListToDataTable(List<WindowsFormsApplication1.ServiceReference1.ArrayOfString> list)
  2. {
  3. // New table.
  4. DataTable table = new DataTable();
  5.  
  6. // Get max columns.
  7. int columns = list[0].Count();
  8.  
  9. // Add columns.
  10. for (int i = 0; i < columns; i++)
  11. {
  12. table.Columns.Add();
  13. }
  14.  
  15. // Add rows.
  16. foreach (var array in list)
  17. {
  18. table.Rows.Add(array);
  19. }
  20.  
  21. return table;
  22. }
  23.  
  24. List <WindowsFormsApplication1.ServiceReference1.ArrayOfString> list = cont.GetAllEmployee();
  25.  
  26. DataTable table = ConvertListToDataTable(list);
  27. dataGridView.DataSource = cont.GetAllEmployee();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement