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

How to ignore column when editing

1 Answer 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce Hochstetler
Top achievements
Rank 2
Bruce Hochstetler asked on 10 Apr 2009, 08:20 PM
Hi,

I data bind my grid with a DataTable that has a column that holds an object that contains information on that row of data. In the grid I obviously don't display it (Display="false" Visible="false" ReadOnly="true"). When I do an 'Add', I get the 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'AttachmentInfo' error. Does anyone know of a way to get the insert edit panel to ignore this column?

Thanks,
Bruce

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 13 Apr 2009, 03:48 PM
Hello Bruce,

The reason for this error and the solution for it are explained in this article from the online documentation:

http://www.telerik.com/help/aspnet-ajax/grderrormessages.html

In cases when you have custom collection of objects for grid source, you can create an empty instance of this object inside the ItemCommand handler on init insert action. Here is some pseudo code:

Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand  
  If e.CommandName = RadGrid.InitInsertCommandName Then '"Add new" button clicked  
    e.Canceled = True 
    'Prepare an IDictionary with the predefined values  
     Dim myObj As [My_Obj_Type_Here]= New [My_Obj_Type_Here]()  
     'Insert the item and rebind  
     e.Item.OwnerTableView.InsertItem(myObj)  
  End If 
End Sub  

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Bruce Hochstetler
Top achievements
Rank 2
Answers by
Sebastian
Telerik team
Share this question
or