This is a migrated thread and some comments may be shown as answers.

Using dropdown to populate Gridview

2 Answers 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
raghav m
Top achievements
Rank 1
raghav m asked on 20 Jan 2010, 03:52 AM
Hi,

Im new to silverlight , i m looking for a code snippet for populating the gridview using dropdown , using sql.

dropdown contains list of years and i want to display the information related to the particular year using sql .

if any one can post the code snippet or a link where i can learn and accomplish this task , would be more help ful.



thanks in advance.
raghav

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 20 Jan 2010, 10:28 AM
Hi,

I've made for you small example to illustrate you how to achieve this completely codeless using WCF RIA Services.

For my example I've used Northwind Customers / Orders with single additional method to the service:

public IQueryable<Order> GetOrdersByCustomerID(string customerID)
{
    return this.DataContext.Orders.Where(o=>o.CustomerID == customerID);
}


You can bind the combo to your first DomainDataSource to display Customers:
<riaControls:DomainDataSource x:Name="DomainDataSource1" AutoLoad="True" QueryName="GetCustomers">
    <riaControls:DomainDataSource.DomainContext>
        <web:NorthwindDomainContext />
    </riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>
 
<telerikInput:RadComboBox x:Name="RadComboBox1" SelectedValuePath="CustomerID" DisplayMemberPath="CompanyName" ItemsSource="{Binding Data, ElementName=DomainDataSource1}" />

and bind the grid using second DomainDataSource to display selected Customer Orders:
<riaControls:DomainDataSource x:Name="DomainDataSource2" QueryName="GetOrdersByCustomerID">
    <riaControls:DomainDataSource.DomainContext>
        <web:NorthwindDomainContext />
    </riaControls:DomainDataSource.DomainContext>
    <riaControls:DomainDataSource.QueryParameters>
        <riaControls:ControlParameter ControlName="RadComboBox1" ParameterName="customerID" PropertyName="SelectedValue" RefreshEventName="SelectionChanged" />
    </riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>
 
<telerikGrid:RadGridView ItemsSource="{Binding Data, ElementName=DomainDataSource2}"  IsBusy="{Binding IsLoadingData, ElementName=DomainDataSource2}" />

The result:



You can check the attached application for reference.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
raghav m
Top achievements
Rank 1
answered on 20 Jan 2010, 11:32 AM
Thanks a ton Vlad,

Vlad
Tags
GridView
Asked by
raghav m
Top achievements
Rank 1
Answers by
Vlad
Telerik team
raghav m
Top achievements
Rank 1
Share this question
or