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

URGENT : Binding Radgrid with multiple data sources

5 Answers 393 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 04 Apr 2011, 01:33 PM
Hi All,

This is an urgent need so your prompt response will be highly appreciated.

In our project we have a silverlight radgrid and we need to bind different columns of this grid with different data sources. For example, suppose I have 3 columns in the grid and the last (i.e, 3rd) column contains a dropdown. Now the complete grid is populated by using an observable collection while the last column containing drop down is populated by some another observable collection. The problem we are facing at present is that we are not able to see the data in the dropdown. Here is what we are doing:

In the XAML file:
<telerik:RadGridView x:Name="grid" AutoGenerateColumns="False" >           
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
                <telerik:GridViewDataColumn Header="Age" DataMemberBinding="{Binding Age}" />
                <telerik:GridViewComboBoxColumn Header="Country" DataMemberBinding="{Binding CountryID}"
                                   UniqueName="Country" SelectedValueMemberPath="CountryID"
                                   DisplayMemberPath="CountryName">
                </telerik:GridViewComboBoxColumn>
            </telerik:RadGridView.Columns>
 </telerik:RadGridView>

In the code behind file:

grid.ItemsSource = lstTestData;
((GridViewComboBoxColumn)this.grid.Columns["Country"]).ItemsSourceBinding = lstCountry;

Here,

lstTestData : is the observable collection we are fetching from web service to bid the grid
lstCountry : is another observable collection we are fetching from web service specifically for combo box

Can you please urgently share your thoughts/comments with me. It would be great if you could please provide some code snippet along with that as well.

Cheers,
Shiva

5 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 04 Apr 2011, 01:36 PM
Hi Shiva,

Please try replacing :
((GridViewComboBoxColumn)this.grid.Columns["Country"]).ItemsSourceBinding = lstCountry;

with the following :
((GridViewComboBoxColumn)this.grid.Columns["Country"]).ItemsSource = lstCountry;

This should help.

Kind regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shiva
Top achievements
Rank 1
answered on 04 Apr 2011, 01:44 PM
Dear Pavel,

Thank you for your quick response. I tried your suggested solution but that didn't help. Although, now I'm getting one of the combo box values selected (based on what we get from database) but still the combo box appears blank. Please find attached the snapshot of the same.

For example, I get three countries from databse having key - value pair (1-India, 2-USA, 3-UK). If I get 3 as CountryID from web service call then I can see UK selected in the combo box but when I click on the combo box to open it and see the other countries (i.e. India and USA), i cannot see it. Combo box appears to be blank.

Can you please suggest something??

Warm regards,
Shiva
0
Pavel Pavlov
Telerik team
answered on 04 Apr 2011, 01:52 PM
Hello Shiva,

Without having more info , I can just guess what may be gone wrong. The first think I would check is the output window - can you please check if you are getting any binding expression errors in the Visual Studio  output , when starting the application .

Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shiva
Top achievements
Rank 1
answered on 04 Apr 2011, 02:04 PM
Hi,

Yes.. I'm getting this error..

System.Windows.Data Error: BindingExpression path error: 'CountryName' property not found on 'ComboBoxPOC.Country' 'ComboBoxPOC.Country' (HashCode=53442317). BindingExpression: Path='CountryName' DataItem='ComboBoxPOC.Country' (HashCode=53442317); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')..




Can you please help?
0
Shiva
Top achievements
Rank 1
answered on 04 Apr 2011, 02:07 PM
Hi,

I got it. It was silly mistake at my end. I had private property in my collection and that is why was getting this error. It works great now.

Thanks for your help.

Cheers,
Shiva
Tags
GridView
Asked by
Shiva
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Shiva
Top achievements
Rank 1
Share this question
or