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

[Solved] Insert vs. Edit

5 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Wolfe
Top achievements
Rank 1
Steve Wolfe asked on 20 Jan 2010, 10:38 PM
I have a customvalidator a DataBoundColumn in a RadGrid.  In the validator I need to know whether I am inserting a new item or editing an old item in the ServerValidate handler.

Is there any well to tell at that point?

Also, while in the ServerValidate handler is there a way to get the previous value of the control?


Thanks,
Steve

5 Answers, 1 is accepted

Sort by
0
Steve Wolfe
Top achievements
Rank 1
answered on 20 Jan 2010, 11:02 PM
In continueing to play around here. I think what I might want to do is find the EditFormItem asssociated with the control that I am validating.

From there I can get access to the SavedOldValues.

Would anyone have ideas on how to do that?

-Steve
0
Accepted
Veli
Telerik team
answered on 25 Jan 2010, 11:19 AM
Hi Steve,

If you can reference your validated control (let's say its ID is TextBox1), you can use:

GridEditableItem editedItem = TextBox1.NamingContainer as GridEditableItem;

The NamingContainer property of the control inside the edited item references the item itself, unless you are searching from a control inside another databound control in the edited item. Once you find the edited item, you can check if editedItem.OwnerTableView.IsItemInserted. If the value is true, you have an insert, if the value is false - the edit operation is taking place.

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Steve Wolfe
Top achievements
Rank 1
answered on 25 Jan 2010, 05:16 PM
Veli,  thanks that works for the second question in the initial post. 

But for the first, is there a "correct" way to tell when in EditMode if it is for an Insert or an Edit?

-Steve
0
Veli
Telerik team
answered on 26 Jan 2010, 08:32 AM
Hello Steve,

As mentioned in the last sentence of my previous post, you can use the GridTableView.IsItemInserted property. A value of true indicates an item is inserted, a value of false indicates an item is edited.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Steve Wolfe
Top achievements
Rank 1
answered on 26 Jan 2010, 04:43 PM
Veli,

Sorry I mssed that.  Thanks for the help.

-Steve
Tags
Grid
Asked by
Steve Wolfe
Top achievements
Rank 1
Answers by
Steve Wolfe
Top achievements
Rank 1
Veli
Telerik team
Share this question
or