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

SelectionChanged not firing

2 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve Chadbourne
Top achievements
Rank 1
Steve Chadbourne asked on 25 Jan 2012, 09:40 PM
I click a row in my grid and SelectionChanged fires.

In the event handler I call UnselectAll()

If I click in the same cell in the same row as before SelectionChanged does not fire. If I click in a different cell in the same row SelectionChanged does fire.

How do I get SelectionChanged to fire when I click in the same cell/row a second time?

I have set SelectionUnit to FullRow and SelectionMode to Single.

Any ideas?

Cheers

Steve

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 26 Jan 2012, 03:01 PM
Hi Steve,

The reason this happens is because the CurrentCellInfo remains unrefreshed. The solution would be something like: 

void GridView_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            this.GridView.UnselectAll();
 
            this.GridView.CurrentCellInfo = new GridViewCellInfo(new object(), this.GridView.Columns[0]);
        }

I am a bit puzzled however. What is the point to unselect  all items on selection changed? This causes the event to fire once on the actual selecting, and one more time when you call UnselectAll(). If the goal is to not let the user select you can set the CanUserSelect property to false. Is that the functionality you are looking for?

Hope this helps! Regards,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Steve Chadbourne
Top achievements
Rank 1
answered on 26 Jan 2012, 08:01 PM
Thanks Nik. I'll try your solution.

I only call UnselectAll after I grab the SelectedItem and show an edit screen. The reason I do this is to allow the user to select the same row again after it has edited. If I don't do this SelectionChanged will not fire (I believe).

Cheers

Steve
Tags
GridView
Asked by
Steve Chadbourne
Top achievements
Rank 1
Answers by
Nick
Telerik team
Steve Chadbourne
Top achievements
Rank 1
Share this question
or