Selected row is always the last row when I select

4 posts, 0 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 12 Sep 2010 Link to this post

     

     

     

    I'm binding data from an observable collection to the datagrid.  For some reason with this one, when click on any of the rows, the last one always gets selected instead of the row that should be.  In my code, I'm adding to the observable collection on a button click unrelated to the gridview.


    <
    telerik:RadGridView x:Name="rgvBillingContacts" HorizontalAlignment="Left" Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2"

     

     

     

    Margin="30,10,0,0" Height="210" Width="435" SelectionMode="Single" AutoGenerateColumns="False"

     

     

     

    ScrollViewer.HorizontalScrollBarVisibility="Visible"

     

     

     

    IsSynchronizedWithCurrentItem="True"

     

     

     

    ActionOnLostFocus="None"

     

     

     

    RowIndicatorVisibility="Visible"

     

     

     

    CanUserDeleteRows="True"

     

     

     

    IsReadOnly="False"

     

     

     

    SelectionUnit="FullRow"

     

     

     

    ItemsSource="{Binding ocBillingContacts}"

     

     

     

    >

     

     

     

     

    <telerik:RadGridView.Columns>

     

     

     

     

    <telerik:GridViewColumn>

     

     

     

     

    <telerik:GridViewColumn.CellTemplate>

     

     

     

     

    <DataTemplate>

     

     

     

     

    <telerik:RadButton Content="Delete" Command="telerik:RadGridViewCommands.Delete" CommandParameter="{Binding}" />

     

     

     

     

    </DataTemplate>

     

     

     

     

    </telerik:GridViewColumn.CellTemplate>

     

     

     

     

    </telerik:GridViewColumn>

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding AddressId}" IsReadOnly="True" IsVisible="False" Header="key" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" IsReadOnly="True" Width="150" Header="Name" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Title}" IsReadOnly="True" Width="100" Header="Title" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding CompanyName}" IsReadOnly="True" Width="100" Header="Company" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Address1}" IsReadOnly="True" Width="100" Header="Address1" />

     

     

     

     

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Address2}" IsReadOnly="True" Width="100" Header="Address2" />

     

     

     

     

    </telerik:RadGridView.Columns>

     

     

     

     

    </telerik:RadGridView>

     

  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 14 Sep 2010 Link to this post

    Hi Dan,

    Could you please send us a sample application that demonstrates this issue?


    Regards,
    Milan
    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
  3. DevCraft banner
  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 14 Sep 2010 Link to this post

    Ok when making the sample, I found that I can't make the class that I'm adding to my observable collection global.


        public partial class Screen9 : Page 
        
        
            ObservableCollection<BillingContacts> ocBillingContacts = new ObservableCollection<BillingContacts>(); 
        
        
            BillingContacts currentCCAdd = new BillingContacts(); //THIS WILL FAIL UP HERE 
        
    ... Init... 
        
            private void btCC_Click(object sender, RoutedEventArgs e) 
            
               BillingContacts currentCCAdd = new BillingContacts(); //Correct SPOT!! 
               //Fillup currentCCAdd  
               ... 
                ocBillingContacts.Add(currentCCAdd); 
            
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 17 Sep 2010 Link to this post

    Hi Dan,

    Yes, you will have to create a different instance every time you want to add a new item.


    All the best,
    Milan
    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
Back to Top