Click here to Skip to main content
13,091,145 members (62,506 online)
Rate this:
Please Sign up or sign in to vote.
Hi everyone,
I am trying to biding data for a database in SQL server 2012 on SilverLight application.
But, when i was following this tutorial for beginner at 16th step, i could not find out my
"context" ( "OrganizationContext" in the tutorial) to get data from my database.

This is that tutorial:[^]

I don't know where the code, is generated from my database, is in my project. I tried to find "context" in the sample of this tutorial, it's difinited in HRapp.Web.g.cs file of sample, which i can't find out where it's in project folder in window explorer.

Please someone show me how to get my "context" to get data from database or give me a hint/guide to binding data from SQL2012 database to datagrid in SilverLight.

P/s: my English is bad. Please forgive me. And i tried many tutorial but non of them guide me how to binding with SQL2012 in SilverLight App.
Posted 22-Apr-13 0:08am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you done every thing correctly, the below line would be binding statement for c#.
this.dataGrid1.ItemsSource = _OrganizationContext.Employees

and for VB.NET is :
Me.dataGrid1.ItemsSource = _OrganizationContext.Employees

They both are located in coding block in 16th step.

* Do not forget to initialize it
* If you don't get the data that you see on the sample, review your code starting from step 7th
* some people might have a little problem with Step 11 & Step 12, if they do not understand XAML. Make sure that you do these steps correctly.
* Make sure you have some data in your database

The execution flow of the code in step 16:
-> First, it initializes the context (this is probably the one that you are looking for
OrganizationContext _OrganizationContext = new OrganizationContext();

-> In Constructure, it initializes the Silverlight Components (things that defined in XMAL)

-> Bind the data grid on UI with the context
this.dataGrid1.ItemsSource = _OrganizationContext.Employees

-> Load data to context Object

Since ItemsSource of dataGrid1 references to Employees Property of OrganizationContext. So when you do _OrganizationContext.Load you data is updated and so should your view.

If this still does not work, try
this.dataGrid1.ItemsSource = _OrganizationContext.Employees;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100