Windows Scripting
  Home arrow Windows Scripting arrow Page 5 - Introducing Two-Way Data Binding using Sil...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Introducing Two-Way Data Binding using Silverlight 2.0, WCF and LINQ to SQL
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2008-11-19

    Table of Contents:
  • Introducing Two-Way Data Binding using Silverlight 2.0, WCF and LINQ to SQL
  • Developing a Silverlight 2.0 page to demonstrate Insert functionality
  • Developing a Silverlight 2.0 page to demonstrate Add functionality, continued
  • Developing a Silverlight 2.0 page to demonstrate Add functionality: Using two-way binding
  • Explaining two-way binding

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introducing Two-Way Data Binding using Silverlight 2.0, WCF and LINQ to SQL - Explaining two-way binding


    (Page 5 of 5 )

    Let us have a look at the textboxes' definitions:


    <TextBox Margin="8,8,46,8" Grid.Column="1" Text="{Binding Empno, Mode=TwoWay }" TextWrapping="Wrap" x:Name="txtEmpno" />

     <TextBox Margin="8,8,46,8" Text="{Binding Ename, Mode=TwoWay }" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1" x:Name="txtEname"/>

     <TextBox Margin="8,8,46,8" Text="{Binding Sal, Mode=TwoWay }" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="2" x:Name="txtSal"/>

     <TextBox Margin="8,8,46,8" Text="{Binding Deptno, Mode=TwoWay }" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="3" x:Name="txtDeptno"/>


    The most important property (say attribute) to examine in all of the above textboxes is the "Text" with "Binding" specification. The binding specification includes the word "Binding" followed by a property name and the "Mode," which is "TwoWay."

    Once the "Mode" is provided as "TwoWay" and the user has modified any text in the textboxes, the business object (say "Emp" object in this case) automatically reflects the changes. Similarly, if business object values are modified, it would automatically be reflected in the controls.

    The business object will generally be assigned to a container control with the help of the "DataContext" property. Once the container control receives the object, it passes the object to all of its child controls and each of the child controls pull whatever information they require (using the Binding specification).

    In our case, the DataContext property is set in code-behind as follows:


    Private objEmp As EmpService.Emp


    Public Sub New()

    InitializeComponent()

    objEmp = New EmpService.Emp

    Me.LayoutRoot.DataContext = objEmp

    End Sub

    All of the information in "objEmp" is automatically carried to textboxes and vice versa (which is two-way binding).

    In my upcoming articles, we will see more and more examples of Silverlight 2.0 development together with LINQ to SQL and WCF. I hope you enjoyed the article; any suggestions, bugs, errors, enhancements etc. are highly appreciated at http://jagchat.spaces.live.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello guys,This is my next article in the series focusing on "Silverlight 2.0...
       · Hi,Can you please also discuss on how to do Two way data binding for a combo box...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT