Skip to main content
Home Forums Silverlight Programming Programming with .NET - General How to display different values in combobox of datagrid
5 replies. Latest Post by spatemp on November 7, 2009.
(0)
spatemp
Member
4 points
32 Posts
11-06-2009 8:06 PM |
For example, lets say I have countries displayed in one column of grid and I want to display cities in second column based on the country. How do you do that. I need an example of that please. So, basically the dropdown in second column has different values based on the first column of the Grid. Thanks.
Ardman
Contributor
3128 points
868 Posts
11-07-2009 5:06 AM |
You would need to do this from your query. As you'll know what the Country is, you'll need a relationship in your database to marry the Country to the Cities maybe by a CountryID in your Cities table.
11-07-2009 8:17 AM |
yes. I got that. but I am little foggy on the xaml and the way you would bind it to grid is what I need. So, quick small little example would be great. So, would my object that would bind to grid(say Countries) would it have collection of Cities property(populated appropriately for each country from db).
11-07-2009 3:19 PM |
All you need to know :
http://www.silverlight.net/learn/videos/all/silverlight-data-part1/
11-07-2009 5:17 PM |
yea. I watched this video before and it does not help me with what I am looking for. So, let me try to ask this question in another way.
Suppose I have ObservableCollection<Countries> bound to grid. And Countries has property CountryName, Population, and Capital(int cityId). Now lets say that I have another ObservableCollection<Cities> that I would like to bind to grid's Templated ComboBox column. So Grid has CountryName, Population and City(templated ComboBox) columns. I would like City column to be bounded to ObservableCollection<Cities>. Cities class has two property CityName and CityId. And CityName is what we want to display in Grid in ComboBox column.
Is this possible and what would xaml for grid look like.
11-07-2009 8:35 PM |
I believe this is what I am looking for.
http://weblogs.asp.net/manishdalal/archive/2008/09/28/combobox-in-datagrid.aspx