This is a migrated thread and some comments may be shown as answers.
bindinglist and modification
1 Answer 33 Views
This is a migrated thread and some comments may be shown as answers.
Guillaume
Top achievements
Rank 1
Guillaume asked on 18 Mar 2010, 04:04 PM
Hello,

I put a bindingList (loaded with database content) in my grid's DataSource.

Oon RowValidated, I want to save the added/modified Data item to the database.

Is there a safe way to know if RowValidated is after an Add, or an Edit ?

Thanks,

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 23 Mar 2010, 11:45 AM
Hello Guillaume JAY,

You have two options to solve this issue:

1. You can check whether the Row property of the event argument is GridViewNewRowInfo. In this case you are validating a new row

2. You should get the DataBoundItem property of the row and check the RowState property. However, this will only work when the underlying data source is DataTable.
void radGridView1_RowValidating(object sender, RowValidatingEventArgs e)
{
    DataRowView dataRowView = e.Row.DataBoundItem as DataRowView;
    if (dataRowView != null)
    {
        bool addedRow = dataRowView.Row.RowState == DataRowState.Added;
    }
}

In addition, you can use the Tag property of GridViewRowInfo to save custom information. I hope this helps.

Best wishes,
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.
Asked by
Guillaume
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or