Hello,
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:
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?
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);
MessageBox.Show(selectedItem.ID.ToString());
}
}
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?