Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. private void LoadProducts()
  2. {
  3. try
  4. {
  5. db = new Db();
  6. var gridvResult = (from u in db.Products
  7. join c in db.Categories on u.CatId equals c.CategoryId
  8. select new
  9. {
  10. PrId = u.ProductId,
  11. ProductName = u.ProductName.Substring(5), // Here I get error
  12. CategoryName = c.CategoryName,
  13. }).ToList();
  14.  
  15. if (gridvResult != null)
  16. {
  17. dgvProduct.DataSource = null;
  18. dgvProduct.DataSource = gridvResult;
  19. dgvProduct.Columns[0].Visible = false;
  20. }
  21. }
  22. catch (Exception ex)
  23. {
  24. MessageBox.Show(ex.Message);
  25. Exception inner = ex.InnerException;
  26. while (inner != null)
  27. {
  28. MessageBox.Show(inner.Message);
  29. inner = inner.InnerException;
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement