SelectedItems Not Working

2 posts, 0 answers
  1. Frustrated Dev
    Frustrated Dev avatar
    35 posts
    Member since:
    Oct 2006

    Posted 01 Dec 2010 Link to this post


    I am using the RadGridView control to allow a user to select one or more items. In certain cases, a user will select one row in the grid. To accomplish this, I have set the "SelectionUnit" property to "FullRow". To respond accordingly to the user's interaction, I have written an event handler for the SelectionChanged event. This is where my problem comes in.

    In the case that the user has selected a single row, I want to get the ID for that object. I am doing this using the following code:
    private void myGridView_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangeEventArgs e)
      RadGridView gridView = (RadGridView)(sender);
      if (gridView.SelectedItems.Count == 1)
        MyProxy.MyClass selectedItem = (MyProxy.MyClass)(gridView.SelectedItem);

    The first time I select a row in the grid, the ID displays properly. However, on following attempts, the previously selected id is selected. I've noticed that if I select the same row twice, the correct ID appears on the second attempt.

    What am I doing wrong? How do I get the id of the currently selected item in the grid?
  2. Milan
    Milan avatar
    1989 posts

    Posted 05 Dec 2010 Link to this post

    Hello Frustrated Dev,

    I couldn't reproduce this issues. Could you please try to reproduce it with the attached sample?

    Kind regards,
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top