Link to home
Start Free TrialLog in
Avatar of sr2007
sr2007Flag for United States of America

asked on

Fill ObservableCollection with database query

I am using Silverlight 4 and SharePoint and want to fill an ObservableCollection from a returned dataset from SharePoint. I have the query and connection to SharePoint done. In my example my List is called _getList and my ListCollectionItems is called _getListItems. My query returns a dataset of x amount of rows of data from an Employee table.

How do I iterate through the returned dataset (_getListItems) and populate Silverlight's ObservableCollection so that I may perform binding and validation on the controls (i.e. textboxes, listboxes, comboboxes, etc.)?
Avatar of ambience
ambience
Flag of Pakistan image

Using untyped datasets?

Can you change the query to return an Observable collection instead? (if thats in your control)

Alternatively, you may have to create a model class and loop through returned rows to populate the observablecollection. This shouldn't be difficult, however two way binding may require sending updates back to the database?

Check this

http://social.expression.microsoft.com/Forums/en/blend/thread/3772bf00-06a2-466a-8a56-49ed8c5a471b

It shows how to fill a List, but can be changed to return an ObservableCollection instead.
ASKER CERTIFIED SOLUTION
Avatar of Sathish DV
Sathish DV
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial