Visual Studio 2010!

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
Using Query Data With Silverlight 4 DomainDataSource
By DevSource

Rate This Article: Add This Article To:

Adding onto last week's Silverlight Tutorial where we discussed the DomainDataSource, ASPFree brings a second part of the tutorial. In this article, the use of query data parameters is discussed and best practices of integrating query parameters into Silverlight 4.0 are explained.

To read this code tutorial in its entirety, please visit ASPFree.com: Silverlight 4.0: Query Parameters of DomainDataSource - A Second Glance

The content in the second row of the form is filled with the “DataGrid” as shown below:

        <sdk:DataGrid Grid.Row="1"
            x:Name="dgEmp"
            Margin="8" MinHeight="200" IsReadOnly="True"
            AutoGenerateColumns="True"
            ItemsSource="{Binding Data, ElementName=EmpDomDataSource}" />

The above “DataGrid” fills the entire space in the second row until it reaches the maximum width/height of the form. Furthermore, it is bound to “EmpDomDataSource,” which is defined as follows:

    <UserControl.Resources>
        <riaControls:DomainDataSource x:Name="EmpDomDataSource"
                                      LoadSize="15"
                                      QueryName="GetEmpsByDeptno"
                                      AutoLoad="True">
            <riaControls:DomainDataSource.DomainContext>
                <local:EmpMgrDomainSvc></local:EmpMgrDomainSvc>
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="deptno" Value="{Binding ElementName=txtDeptno, Path=Text}"/>
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>
    </UserControl.Resources>

The above markup explains the following:

  • We define a DomainDataSource element named “EmpDomDataSource”
  • It is bound to “EmpMgrDomainSvc” (nothing but context).
  • It pulls data using “GetEmpsByDeptno” (an entity query of the domain service context).
  • The query “GetEmpsByDeptno” accepts a parameter named "deptno."
  • The parameter value is directly taken from an existing control, "txtDeptno."



Discuss Using Query Data With Silverlight 4 DomainDataSource
 
>>> Be the FIRST to comment on this article!
 

 
 
>>> More News Articles          >>> More By DevSource