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

Rad Grid Row Edit, RowChanged event triggers if null values are present in row cells

3 Answers 799 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike Treat
Top achievements
Rank 1
Mike Treat asked on 26 Mar 2010, 11:46 AM
I'm having an issue with  RadGridView1_RowsChanged event. Normally this event will trigger if I modify the row content and moved to another row. If the row contains a cell with NULL values and I clicked on that cell and without editing I moved to another row, then also the RadGridView1_RowsChanged event triggered which is causing me issue. What I'm trying to do in my project is that I need to get the edited row details and update that to database on a button click. If I go through a null cell and moved to another row then also RadGridView1_RowsChanged event triggerd and my edited row index valu will change and I'm not able to save the details to database.  Some part of my code is given below. Can anybody help me?
 private void radGridHome_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)  
        {  
            try  
            {  
                if (isGridLoadCompleted)  
                {  
                    isRowsChanged = true;  
                    //Getting the edited rows index   
                    previousRowIndex = e.NewStartingIndex;  
                    if (!arrRowChangedIndex.Contains(e.NewStartingIndex))  
                    {  
                        arrRowChangedIndex.Add(e.NewStartingIndex);  
                    }  
                    Console.WriteLine("RowsChanged @ " + e.NewStartingIndex + e.OldStartingIndex + "  ");  
                }  
            }  
            catch (Exception ex)  
            {  
                WriteLogFile(ex.ToString(), "radGridHome_RowsChanged");  
            }  
        }  
 
 private void radGridHome_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)  
        {  
            try  
            {  
                if (isGridLoadCompleted && isRowsChanged && chkSaveExitingRow.Checked)  
                {  
                    // Updating the edited row details to datatbase  
                    UpdateCustomerOrderInfo(chkSaveExitingRow.Checked, false, previousRowIndex);  
                    isRowsChanged = false;  
                }  
                arrPastRowValue.RemoveRange(0, arrPastRowValue.Count);  
            }  
            catch (Exception ex)  
            {  
                WriteLogFile(ex.ToString(), "radGridHome_CurrentRowChanged");  
            }  
        } 

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 29 Mar 2010, 02:36 PM
Hello Mike Treat,
 
I am not sure that I understand your updating logic. However, it will be better to use the RowValidating and RowValidated events in this case. These events fire before changing the current row and allow you to validate and save the changes. Maybe it will be better to commit changes to the data base at single when closing the form.
 
Please describe with more detail your scenario and/or send me your application in a new support ticket. This way I will be able to be more specific in my suggestions. I am looking forward to your reply.

Kind regards,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Mike Treat
Top achievements
Rank 1
answered on 30 Mar 2010, 05:26 AM
thanks for the reply Jack, I know that my updating logic is a bit different, because I'm not that familier with rad controls and their events. but  
I have tried  both RowValidating and RowValidated events. The issue in these events is that it will be triggering even if the row data is changed. I need an event which will be triggered or called only if the content in thta row is changed. I found that RowsChanged event will trigger if the row content is changed but in case if the row cell contains a null value and we clicked on that and moved to another row then also this event will trigger. This is where I'm having issues.
0
Svett
Telerik team
answered on 01 Apr 2010, 12:54 PM
Hi Mike Treat,

RowValidating and RowValidated events are fired when you change the current row. There are also some exceptions if the current row is the new row. Then the events are fired when the grid loses focus or you click on the empty area of the grid. There are 2 events that handle value changes. The first event ValueChanged is fired when the value of the editor is changed, but not committed to your data source. The other event is CellValueChanged which occurs when the value from editor is applied to the cell. This happens when you go in another cell or row.

You can read more about these events in this documentation article.

If you have further questions, feel free to write us back.

Kind regards,
Svett
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Mike Treat
Top achievements
Rank 1
Answers by
Jack
Telerik team
Mike Treat
Top achievements
Rank 1
Svett
Telerik team
Share this question
or