How To Bind Objects To a DataGird ?

Y

yaniv abo

Hello.



How can I bind a list of objects to a DataGird?

I have a custom collection of Customer class



class Customer {

Public String Name;

Public String Addres;

….

}



How do I bind the collection to a data grid and the data grid will provide
the options to add\modify\delete customers from the collection.



If I put the Customers in an ArrayList data grid only display the data and
I’m unable to edit it.





Any help will be appreciated.





Yaniv abo

(e-mail address removed)
 
P

Phil Wright

The ArrayList does not provide the interface you need in order to edit back.
The easiest way is just to populate a DataTable with one row per customer
and then bind the DataTable to your DataGrid instance. Then you can
edit/remove/add entries. When finished you can easily scan over the list of
rows in the data table and find the ones that are new (create a new matching
customer record), edited (update your existing customer record) or marked
for deletion (remove it from your customers collection).

Hope that helps
Phil Wright
Follow my microISV startup at....
http://componentfactory.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top