Click here to Skip to main content
Click here to Skip to main content
Go to top

[Silverlight] Work with Cascading Drop-down Lists in the Telerik Gridview Control

, 23 Aug 2012
Rate this:
Please Sign up or sign in to vote.
Work with Cascading Drop-down Lists in the Telerik Gridview Control

Editorial Note

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

Introduction

How to work with cascading drop-down lists in the Telerik gridview control?

The Solution

I am explaining how to work with cascading drop-down lists in the Telerik gridview control. The overall approach is pretty much the same. To review, when you're working with cascading DropDownList controls, you need to perform these tasks:

  • Populate each of the DropDownList controls.
  • Pre-select the appropriate value in each list to match what's currently in the data.
  • When the user selects a new value in the master dropdown, repopulate the detail dropdown with a new set of dependent values.

Here information about the schema of the tables is involved in this exercise.

Here you go:

Table: City (ID,Name,ContinentCodel)

Table: Continent(Code,Name)

As I say, you can do this in the GridView control in a way similar, but not identical to how you do it in Page. Let's say you have a grid that looks like this in normal mode:

<telerik:radgridview x:name="radGridView" autogeneratecolumns="True">
</telerik:radgridview>

And looks like this:

When configuring columns that time set AutoGenerateColumns="False" and add columns like:

    <telerik:radgridview.columns>
			<telerik:gridviewcomboboxcolumn datamemberbinding="
			{Binding ContinentCode, Mode=TwoWay}" header="Continent" 
			displaymemberpath="Name" selectedvaluememberpath="Code">
			<telerik:gridviewcomboboxcolumn itemssourcebinding="
			{Binding AvailableCountries}" datamemberbinding="{Binding CountryID}" 
			header="Country" displaymemberpath="Name" 
			selectedvaluememberpath="ID" width="400">
		</telerik:gridviewcomboboxcolumn></telerik:gridviewcomboboxcolumn>
		</telerik:radgridview.columns>

When Continent changes that time set country using this code: In Continent selection, changed event looks like: Attached event in MainPage Constructor like:

this.AddHandler(RadComboBox.SelectionChangedEvent, 
new Telerik.Windows.Controls.SelectionChangedEventHandler(comboSelectionChanged));

Selection changed event:

void comboSelectionChanged(object sender, RadRoutedEventArgs args)
        {
            RadComboBox comboBox = (RadComboBox)args.OriginalSource;
            
            if (comboBox.SelectedValue==null 
                || comboBox.SelectedValuePath != "Code")
                return;
            
            Location location = comboBox.DataContext as Location;
            location.ContinentCode = (string)comboBox.SelectedValue;
        }

License

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

Share

About the Author

Savalia Manoj M
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
QuestionHow do i bind a telerik radgrid Griddropdowncolumn with database values? PinmemberAlesha Mary Milred Fernandes29-Apr-14 5:15 
GeneralMy vote of 5 PinmemberChristian Amado23-Aug-12 7:10 
GeneralRe: My vote of 5 PinmemberSavalia Manoj M26-Aug-12 17:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 23 Aug 2012
Article Copyright 2012 by Savalia Manoj M
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid