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

Distinguished if the event fired from insert or add

2 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Web team
Top achievements
Rank 1
Web team asked on 26 Apr 2010, 11:07 AM
During Itemdatabound  event, what is the best way to know if it came from Insert or Edit. Right now Im filtering Itemdatabound  using this condition:

if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)
  
however both Insert and Edit event makes the above statement true.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 26 Apr 2010, 12:16 PM
Hello Arnold,

In order to check whether it is edit or insert operation inside ItemDataBound event,you can use following condition.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
   if(e.Item is GridEditFormItem && e.Item.IsInEditMode)//checking whether it is edit form item
   { 
 
   } 
   if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)//checking whether it is insert form item
   { 
 
   } 

Refer the following documentation for more information about this.Distinguish edit/insert mode.

Regards,
Shinu.


0
Web team
Top achievements
Rank 1
answered on 01 Dec 2010, 07:17 AM
thanks. solves the issue
Tags
Grid
Asked by
Web team
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Web team
Top achievements
Rank 1
Share this question
or