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
830
ObjectDataSource With Custom Object
posted

I have a BLPerson class with:
1. A parameterless constructor called BLPerson()
2. A public static method GetAllPeople that returns a list of type BLPerson
3. An instance void method Save() which persists the BLPerson instance to the db and handles whether it is an insert of update
4. An instance void method Delete() which deletes an instance of a BLPerson

Using the VS designer I have pointed an objectdatasource to the BLPerson calss and successfully set its select method to the GetAllPeople method but am unable to set the insert,update or delete methods as the Save() or Delete() methods are not available for me to select. I then point the objectdatasource to a webgrid do a databind() in the code and successfully populate the grid with rows.

The question is how to I set the Insert update and delete methods

Thanks John

 

 

 

Parents
  • 18204
    Suggested Answer
    Offline posted

    Hi John,

     

    Thank you for posting in our forums!

    The issue here seems to be that you are using instance versions for your Save() and Delete() methods.  I am assuming this means you do not have any parameters declared for these methods.

    The ObjectDataSource recognizes methods that accept a type, e.g. "public void Save(BLPerson obj)" and allows you to work with those.  I would recommend creating a separate BLPersonContainer class to interface with the ObjectDataSource.  You can then use this container to access and modify each individual BLPerson using the BLPersonContainer.Save(BLPerson) and BLPersonContainer.Delete(BLPerson) methods.  Once you make these changes, assigning the DataSourceID of your WebDataGrid to the ObjectDataSource should allow the data to appear in the grid.

    Also since the ObjectDataSource is not an Infragistics control, you may also be able to find other alternatives online to allow you to use a single BLPerson class.  Although the above changes are what I would recommend.

    If you need further assistance with having your data appear in the WebDataGrid or other Infragistics controls, please let me know.

Reply Children
No Data