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

in RowValidating, e.Row.IsModified doesnt show as true, when it should

3 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ShareDocs
Top achievements
Rank 1
ShareDocs asked on 24 Sep 2013, 03:14 PM


Hi, I have a GridView.

when I make a change in a cell of one row, and then I select to add a new row the event grid_RowValidating  its fier but when I do e.Row.IsModified I always get FALSE.

Only if I press in other row before I press to add a new row to the grid.

private void grid_RowValidating(object sender, RowValidatingEventArgs e)
       {
               if (e.Row == null) return;
               if (!e.Row.IsModified) return; 
        
       }



 the way to reproduce this is.

- Edit a cell from the gridView.
- Click to add new Row

e.Row.Index indicate that its checking the row I just edited where i change some value, so it should show me that there is a change.
I also tried adding the event RowChanged  but didnt work
private void grdPirteyMenahel_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
      {
          grid.EndEdit();
      }


3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 27 Sep 2013, 02:59 PM
Hi Lior,

Thank you for writing.

This property works correctly for its purpose. Here is its description "Gets a value indicating whether the row has been modified and changes are not saved in the data layer." As long as a row value changes it is being saved in the data layer so this property will be false in most cases when accessed. However, it serves our internal logic, and this is why it exists.

If you need to identify if a row value is changed the CellValueChanged event is suitable for that. The Tag property of the row can be set in the event mentioned and it can be checked when you need to know if the row is modified.

Please let me know if there is something else I can help you with.

Regards,
Dimitar
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ShareDocs
Top achievements
Rank 1
answered on 29 Sep 2013, 12:53 PM


I need to identify if a row change and see their changes to validate the row
i cannot validate the entire row when only one cell had change.
i need to do this validation when rowValidating or RowChange or something like that, no in Cell Events.

If I make a change in one row, and then i click in other row it works fine.
it gives me the changes I had done and with that I can validate and if its not correct I can undo the changes.

The problem only appear when after making a change in a row, I click to add a new row 
then I dont get changes when calling to (grid.DataSource as DataTable).GetChanges()

0
Dimitar
Telerik team
answered on 02 Oct 2013, 02:12 PM
Hi Lior,

Thank you for writing back.

The described approach does not suggest to validate anything in the CellValueChanged event. In this event you just have to set the row Tag property to a value that we can later use to determine whether or not the row is changed:
void radGridView1_CellValueChanged(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)
{
    e.Row.Tag = true;
}
 
Then can validate the data in the RowValidating by checking the Tag property:
void radGridView1_RowValidating(object sender, Telerik.WinControls.UI.RowValidatingEventArgs e)
{
    if (e.Row.Tag != null && (bool)e.Row.Tag == true)
    {
         //Validate data here
    }
}

Please let me know if there is something else I can help you with. 

Regards,
Telerik

TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS. 
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

Tags
GridView
Asked by
ShareDocs
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
ShareDocs
Top achievements
Rank 1
Share this question
or