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

Cascading ComboBoxColumn & LINQ to SQL Datasource

1 Answer 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 24 May 2011, 06:32 PM
Hello,

I'm using two cascading ComboBoxColumns in my grid

<telerik:RadGridView x:Name="RadGridView1" ItemsSource="{Binding Assigns}" >
<telerik:RadGridView.Columns>
                    <telerik:GridViewComboBoxColumn Header="Client" ItemsSource="{Binding}"    
                        DataMemberBinding="{Binding ClientID}" DisplayMemberPath="Name" SelectedValueMemberPath="ID" />
                    <telerik:GridViewComboBoxColumn Header="Personalist" ItemsSourceBinding="{Binding AvailablePersons}"    
                        DataMemberBinding="{Binding PersonID}" DisplayMemberPath="Name" SelectedValueMemberPath="ID" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

I've followed this thread to achieve same cascading logic with comboboxes, but with LINQ to SQL Datasource  - no luck

DataClassesDataContext db = new DataClassesDataContext();
((GridViewComboBoxColumn)this.RadGridView1.Columns[0]).ItemsSource = db.Clients;
  
this.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(comboSelectionChanged));

private void comboSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RadComboBox comboBox = (RadComboBox)e.OriginalSource;
  
            if (comboBox.SelectedValue == null
                || comboBox.SelectedItem.GetType() != typeof(Client)) 
                return;
  
            Assign assign= comboBox.DataContext as Assign;
            assign.ClientID = (int)comboBox.SelectedValue;
}

This is the part where I got stuck, I've created an extra field AvailablePersons, but I can't get selected ID from first ComboBoxColumn:

public IEnumerable<Person> AvailablePersons
        {
            get
            {
                return from p in db.Persons
                       where p.ClientID == this.ClientID //???????????????????????????
                       select p;
            }
        }

Thank You for any help

1 Answer, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 30 May 2011, 09:50 AM
Hello Martin,

Your code seems OK , I am not sure what went wrong.  If I can have a look at your runnable project or a small repro I will be glad to perform a small debugging session and see what went  wrong.

Sincerely,
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
Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Share this question
or