Solved

DetailsView events: ItemUpdated vs ItemUpdating

Posted on 2012-03-18
5
579 Views
Last Modified: 2012-03-19
Hi:

We're creating some web application using VS 2010 with Visual Basic.

We try to update/delete an existing record using DetailsView associated with AccessDataSource

We configure DetailsView to bind with the AccessDataSource and also configure the AccessDataSource for SELECT, INSERT, UPDATE, and DELETE statements.

In DetailsView we check "Enable Inserting", "Enable Editing", "Enable Deleting"

The problem is that when we try to update a record, after updating data in text boxes of DetailsView and clikcing "Update", the record is not updated in both DetailsView and the real database table.  When we try to delete a record, after clicking "Delete", the record is not deleted. It is still there in both DetailsView and gthe real database table.

We  carefully checked the real database table and all the data is still there after each operation.

We looked into the events of DetailsView, we found they have a bunch of them. Among them are "ItemUpdated", "ItemUpdating", "ItemDeleted", "itemDeleting", etc.

Do we - by ourselves - have to implement the sub's associated with these events so that the records could be updated or deleted OR the auto-genererated code by Visual Studio will implement them for us?

Thanks  a lot,

Somits
0
Comment
Question by:somits
  • 2
  • 2
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 250 total points
ID: 37736987
You should write code for the events you want to handle.
The xxxxx-ing means that the action has not yet happened - you have a chance to cancel for instance.  The xxxx-ed means that the event has happened, so you can't cancel but you might require something else to be done.
0
 

Author Comment

by:somits
ID: 37737136
Hi:

Thanks for the reply.

To be very simple, if we don't write any code for the event, does visual studio IDE generate code that execute the command?

I read the manual of MSDN, it seems VS does this. However, maybe, I missed something while reading.

Thanks,

Somits
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 37737240
The AccessDataSource and the DetailsView should be able to handle the delete operation without writing any code.  All you to do is to define a DeleteCommand, which I see that you are doing.  

Thoughts:

1) Double-check the connection string, to make sure that you are looking in the correct database for the delete operation results.

2) You can attach to the ItemDeleting event handler to verify that the Delete event is getting fired.  

3) Make sure that you are not doing any special processing that could affect how the page performs on the post-back.
0
 

Author Comment

by:somits
ID: 37737517
Hi:

If I want to check the Connect String, how can I do it?
(If I use OleDb..., then I wrote the conn str by my self. )
Does Vs generates this for us and where it is stored?

Thanks,

Somits
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 37739124
The connection string is stored in the web.config file.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question