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

GridView active row issues

3 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Marcelo
Top achievements
Rank 1
Marcelo asked on 02 Sep 2011, 08:37 PM
I have a GridView with a column having two buttons: Edit and Delete. The GridView current item is the row that is highlighted that in some cases happens to be different from the row where the Edit/Delete button was clicked, therefore returning the wrong current item

Example: Grid has 4 rows. Row 1 happens to be highlighted. If the user clicks on either one of the Edit/Delete buttons in Row 2, we get Row 1 current item, instead of Row 2

Below is the XAML declaration for the Grid View

<telerik:RadGridView Grid.Column="0" Grid.Row="0" Width="1324" HorizontalAlignment="Left" Name="grvRetScheduleTerms" VerticalAlignment="Top" AutoGenerateColumns="False"
                     ActionOnLostFocus="None" CanUserFreezeColumns="False" SelectionUnit="FullRow" SelectionMode="Single" IsSynchronizedWithCurrentItem="True"                                      
                     CanUserDeleteRows="True" IsReadOnly="False" CanUserSelect="True" CanUserInsertRows="False" FontSize="16"
                     AddingNewDataItem="grvRetScheduleTypes_AddingNewDataItem" RowEditEnded="grvRetScheduleTypes_RowEditEnded">

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 03 Sep 2011, 11:21 AM
Hello Marcelo,

I have prepared an example project for you that illustrates such a scenario. Please, refer to it..

Best wishes,
Ivan Ivanov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marcelo
Top achievements
Rank 1
answered on 06 Sep 2011, 01:26 PM
Good morning Ivan and thank you. As you indicated, the line below did the trick.

(sender as RadButton).ParentOfType<RadGridView>().CurrentItem = (sender as RadButton).ParentOfType<GridViewRow>().Item;

So, for others running into this, the line above is what is needed (1st line) in the click event of the "Edit" button (as an example).
0
Marcelo
Top achievements
Rank 1
answered on 07 Sep 2011, 01:29 PM
Please delete this post.
Tags
GridView
Asked by
Marcelo
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Marcelo
Top achievements
Rank 1
Share this question
or