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

Adding New Row and Row changed Event

1 Answer 84 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Iron
Veteran
Claude asked on 23 Feb 2021, 08:58 PM
When I click in the top row to type in a new row value, the CurrentRowChanged event is fired.  I have other code in this event, that I do not want to run when adding a new row.  So I need to trap this so the code will not run in the event.  I did not have this problem until I updated to the latest controls.  

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Feb 2021, 09:52 AM
Hello, Claude,

The CurrentRowChanged event is expected to be fired whenever the CurrentRow in RadGridView is changed. Hence, if you have a data row as current and you click the new row, the CurrentRowChanged event gets fired and the new row is current now.

If you want your code not to be executed when the new row is clicked, you can check which row actually triggered the event:
        private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
        {
            if (e.CurrentRow is GridViewDataRowInfo)
            {
                //TODO
                // execute your code here
                Console.WriteLine("data row");
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or