Click here to Skip to main content
Rate this: bad
good
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:
http://code.msdn.microsoft.com/silverlight/Getting-Started-WCF-RIA-1469cbe2[^]
 
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 1:08am
TM500698

1 solution

Rate this: bad
good
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)
 InitializeComponent();
-> Bind the data grid on UI with the context
 this.dataGrid1.ItemsSource = _OrganizationContext.Employees
-> Load data to context Object
 _OrganizationContext.Load(_OrganizationContext.GetEmployeesQuery());
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
 _OrganizationContext.Load(_OrganizationContext.GetEmployeesQuery());
 this.dataGrid1.ItemsSource = _OrganizationContext.Employees;
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 22 Apr 2013
Copyright © CodeProject, 1999-2014
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