PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms How To Bind Objects To a DataGird ?

Reply

How To Bind Objects To a DataGird ?

 
Thread Tools Rate Thread
Old 03-06-2005, 05:48 PM   #1
yaniv abo
Guest
 
Posts: n/a
Default How To Bind Objects To a DataGird ?


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

yanivabo@gmail.com




  Reply With Quote
Old 03-06-2005, 10:10 PM   #2
Phil Wright
Guest
 
Posts: n/a
Default Re: How To Bind Objects To a DataGird ?

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

"yaniv abo" <yanivabo@netvision.net.il> wrote in message
news:exnWcOFaFHA.1152@tk2msftngp13.phx.gbl...
> 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
>
> yanivabo@gmail.com
>
>
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off