Posted By

rengber on 06/09/09


Tagged

c ADONet WinForms Troubleshooting DataGridView Pitfall


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


DataGridView DataBind an Array of Arbitrary Objects


 / Published in: C#
 

Stupidly simple -- just one pitfall: class to be bound must have Get/Set methods for reflection to discover. Which is annoying when it comes to client side classes auto generated from WSDL.

  1. Foo[] foos = new Foo[2];
  2. DataGridView1.DataSource = foos;
  3.  
  4.  
  5. //This works.
  6. public class FooGood
  7. {
  8. public string Bar { get; set; }
  9. public string Baz { get; set; }
  10. }
  11. //This Doesn't
  12. public class FooBad
  13. {
  14. public string Bar;
  15. public string Baz;
  16. }

Report this snippet  

You need to login to post a comment.