Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - 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 - Developing a Silverlight 2.0 page to demonstrate Add functionality, continued


    (Page 3 of 5 )


    This is a continuation from the previous section.


    • Modify "Page2.xaml" as follows:


    <UserControl x:Class="DemoSL.Page2"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Width="400" Height="300" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">

     <Grid x:Name="LayoutRoot" Background="White">


     <Grid.RowDefinitions>

     <RowDefinition Height="0.133*"/>

     <RowDefinition Height="0.137*"/>

     <RowDefinition Height="0.14*"/>

     <RowDefinition Height="0.143*"/>

     <RowDefinition Height="0.147*"/>

     <RowDefinition Height="0.3*"/>

     </Grid.RowDefinitions>

     <Grid.ColumnDefinitions>

     <ColumnDefinition Width="0.35*"/>

     <ColumnDefinition Width="0.55*"/>

     </Grid.ColumnDefinitions>

     <TextBox Margin="8,8,46,8" Grid.Column="1" Text="" TextWrapping="Wrap" x:Name="txtEmpno"/>

     <TextBox Margin="8,8,46,8" Text="" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="1" d:LayoutOverrides="Height" x:Name="txtEname"/>

     <TextBox Margin="8,8,46,8" Text="" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="2" d:LayoutOverrides="Height" x:Name="txtSal"/>

     <TextBox Margin="8,8,46,8" Text="" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="3" d:LayoutOverrides="Height" x:Name="txtDeptno"/>


     <TextBlock Margin="17,8,43,8" Text="Empno:" TextWrapping="Wrap" x:Name="lblEmpno"/>

     <TextBlock Margin="17,8,43,8" Text="Ename:" TextWrapping="Wrap" Grid.Row="1" x:Name="lblEname"/>

     <TextBlock Margin="17,8,43,8" Text="Salary:" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Row="2" d:LayoutOverrides="Height" x:Name="lblSal"/>

     <TextBlock Margin="17,8,43,9.5" Text="Deptno:" TextWrapping="Wrap" Height="23.9" VerticalAlignment="Stretch" Grid.Row="3" d:LayoutOverrides="Height" x:Name="lblDeptno"/>

     <TextBlock Margin="8,8,64,0" Text="" TextWrapping="Wrap" Height="23.9" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Column="1" Grid.Row="5" d:LayoutOverrides="Height" x:Name="lblMsg"/>

     <Button HorizontalAlignment="Stretch" Margin="8,8,90,8" VerticalAlignment="Stretch" Grid.Column="1" Grid.Row="4" Content="Add Employee" x:Name="btnAdd"/>


     </Grid>

    </UserControl>


    The above code creates the following screen:



    In the code behind, modify the "Page2" class as follows:


    Partial Public Class Page2

    Inherits UserControl


    Public Sub New

    InitializeComponent()

    End Sub


    Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnAdd.Click

    Me.lblMsg.Text = "Communicating..."

    Dim objService As New EmpService.EmpServiceClient

    AddHandler objService.AddCompleted, AddressOf AddEmployeeCompleted

    objService.AddAsync(New EmpService.Emp With {.Empno = Me.txtEmpno.Text, .Ename = Me.txtEname.Text, .Sal = Me.txtSal.Text, .Deptno = Me.txtDeptno.Text})

    End Sub


    Private Sub AddEmployeeCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)

    Me.lblMsg.Text = "Added Successfully!"

    End Sub


    End Class


    Press F5 and you should be able to add new employee information (row) to the database using the Silverlight 2.0 page along with WCF and LINQ to SQL.

    If you run into any problems, I dedicated few sections to troubleshooting in my previous article. Please go through all of the troubleshooting steps in my previous article. If  you do that, you should have no problems. If you need a complete walk-through, consider reading my previous two articles.

    More Windows Scripting Articles
    More By Jagadish Chaterjee


       · 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 4 Hosted by Hostway
    Stay green...Green IT