Databinding to a DAL with ObjectDataSource-control: Update OK, Deletenot (debug info provided) pleas

C

cmrchs

Hi,

I'm trying out Databinding to a Data Acces Layer using a GridView and
ObjectDataSource-control

The Update works fine but the Delete-method doesn't ???

<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1"
OnRowUpdating="GridView1_RowUpdating"
OnRowUpdated="GridView1_RowUpdated"
OnRowDeleting="GridView1_RowDeleting"
OnRowDeleted="GridView1_RowDeleted" />

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
TypeName="ProductsDB"
SelectMethod="SelectProducts" InsertMethod="InsertProduct"
UpdateMethod="UpdateProduct"
DeleteMethod="DeleteProduct" DataObjectTypeName="Product"
OnUpdating="ObjectDataSource1_Updating"
OnUpdated="ObjectDataSource1_Updated"
OnDeleting="ObjectDataSource1_Deleting"
OnDeleted="ObjectDataSource1_Deleted" >
</asp:ObjectDataSource>

Following is a printout of some debugged events, so events raised in
the gridView, the ObjectDataSource, the Business Object 'Product' and
the data Acces Layer class 'ProductsDB'

The Update works fine: (I click Update on the 3rd row (= index 2)
containing Product: ID=3 Name='Aniseed S'

GRIDVIEW1_ROWCOMMAND: RowIndex=2 CommandName=Update
GRIDVIEW1_ROWUPDATING: ProductID=3 OldProductName='Aniseed S'
NewProductName='Aniseed Syrup'
PRODUCT CLASS: DEFAULT CTOR
PRODUCT CLASS: PROPERTY SET PRODUCTID
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=3
OBJECTDATASOURCE1_UPDATING:
ProductID=3 ProductName='Aniseed Syrup'
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=3
ProductsDB class (data layer class): UPDATEPRODUCT ProductID=3
ProductName=Aniseed Syrup
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=3
OBJECTDATASOURCE1_UPDATED:
GRIDVIEW1_ROWUPDATED: ProductID=3 OldProductName='Aniseed S'
NewProductName='Aniseed Syrup'


But the Delete doesn't work: (Delete on the 3rd row (= index 2)
containing Product: ID=3 Name='Aniseed Syrup'

GRIDVIEW1_ROWCOMMAND: RowIndex=2 CommandName=Delete
GRIDVIEW1_ROWDELETING: ProductID=3 ProductName=Aniseed Syrup //
UNTIL HERE EVERYTHING OK
PRODUCT CLASS: DEFAULT CTOR
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=0 // PRODUCT INFO
IS LOST ???
OBJECTDATASOURCE1_DELETING:
ProductID=0 ProductName=
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=0
ProductsDB Class (data layer class): DELETEPRODUCT ProductID=0
ProductName=
//
NO PRODUCT TO DELETE IN DAL
PRODUCT CLASS: PROPERTY GET PRODUCTID: ProductID=0
OBJECTDATASOURCE1_DELETING:
GRIDVIEW1_ROWDELETED: ProductID=3 ProductName=Aniseed Syrup

even before calling the Delete method in the DAL, the product-object
is not correctly constructed

how come?

thank you
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top