Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
Adding Rows using Complex Data Source Entity Model
posted

Hi -

I'm using WebDataGrid to render different entity types that contain complex properties. I use  ObjectDataSource to bind this entity with the WebDataGrid. A fake IList<Equipment> is provided to the source provider. Does anyone know if this is supportable or there is a trick to perform the adding of this complex entity to the datasource.

i.e.

<

 

 

asp:ObjectDataSource
 
ID="objDS"
 
runat="server"
  SelectMethod="GetAllEntries"
  InsertMethod="AppendEntry"
  TypeName="WebGridDataProvider<Equipment>"

  DataObjectTypeName="EntityModel.Equipment">
</asp:ObjectDataSource>

public class Equipment
{
   public EquipmentCategory Category { get; set; }
   public string Comment { get; set; }
   public bool IsCritical { get; set; }
}

When setting the manual CRUD I'm doing something like this:

_clickAddRow: 

 

 

 function(event, args)
{
  var grid = this._DataGrid;
  var entity = new Array(['123', 'InvariantName'], 'comments', 'true');
  grid.get_rows().add(entity);
}

The problem occurs at the object data source when it try to convert the Category from object EquipmentCategory. Is there any sample of way to by pass this? I try to set the event Inserting, Inserted of the ObjectDataSource but those events never get fired.

Thanks for any help.