Click here to Skip to main content
15,886,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have set up a DataGrid and bound it to an ObjectDataSource. I have set the DataObjectTypeName property of the ObjectDataSource, so it expects to bind to the business object it is manipulating.

The Update works fine. When I click Delete, however, the corresponding method in the business logic layer is called, but all the fields are empty. I am clearly missing something obvious, but I don't seem to be doing anything different to all the examples I have read.

Does anyone have any idea what I might be doing wrong?


Kind wishes ~ Patrick
Posted

1 solution

Solved this one. It seems I needed to set the DataKeyNames property.

So, I can now do 3 of the 4 CRUD operations. I thought I was home and dry, but now I can't figure out how to add a new record from a DataGrid. Am I correct in thinking that you somehow need to enable an empty row at the end of the DataGrid, so you have somewhere to enter the values for the new record?

I tried doing it by having some separate text boxes on the screen, in which to enter the fields for the new record, but I can't figure out how to get these into the InsertMethod of the ObjectDataSource. I thought I could do this programmatically by creating parameters and adding them to the InsertParameters collection, but I was surprised to find that the Parameter class doesn't seem to have a property to set its value. How do I get a value into it?

Arghhh... I'm going mad with this. Every tutorial I read seems to have some key piece of information missing. Please help!


Kind wishes ~ Patrick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900