Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. public class ListOfProducts
  2. {
  3. [DataMember()]
  4. public List<Product> ProductList { get; set; }
  5.  
  6. public ListOfProducts()
  7. {
  8. ProductList = new List<Product>();
  9. }
  10. }
  11.  
  12. public ListOfProducts GetObject()
  13. {
  14. ListOfProducts Listproducts = new ListOfProducts();
  15. ........
  16. using (IDataReader reader = cmd.ExecuteReader())
  17. {
  18. while (reader.Read())
  19. {
  20. Product product = new Product(reader["Name"].ToString(), reader["Code"].ToString());
  21. Listproducts.ProductList.Add(product);
  22. }
  23. }
  24. return Listproducts;
  25. }
  26.  
  27. void service_GetObjectCompleted(object sender, GetObjectCompletedEventArgs e)
  28. {
  29. if (e.Result.Count != 0) //throws NullReferenceException
  30. {
  31. PagedCollectionView pagingCollection = new PagedCollectionView(e.Result);
  32. pgrProductGrids.Source = pagingCollection;
  33. grdProductGrid.ItemsSource = pagingCollection;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement