Skip to main content

Microsoft Silverlight

Answered Question How to display different values in combobox of datagridRSS Feed

(0)

spatemp
spatemp

Member

Member

4 points

32 Posts

How to display different values in combobox of datagrid

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
Ardman

Contributor

Contributor

3132 points

871 Posts

Re: How to display different values in combobox of datagrid

 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.

spatemp
spatemp

Member

Member

4 points

32 Posts

Re: Re: How to display different values in combobox of datagrid

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).

Ardman
Ardman

Contributor

Contributor

3132 points

871 Posts

Re: Re: Re: How to display different values in combobox of datagrid

 All you need to know Big Smile:

http://www.silverlight.net/learn/videos/all/silverlight-data-part1/

spatemp
spatemp

Member

Member

4 points

32 Posts

Re: Re: Re: Re: How to display different values in combobox of datagrid

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.  

spatemp
spatemp

Member

Member

4 points

32 Posts

Answered Question

Re: Re: Re: Re: Re: How to display different values in combobox of datagrid

I believe this is what I am looking for. 

http://weblogs.asp.net/manishdalal/archive/2008/09/28/combobox-in-datagrid.aspx

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities