Solved

DetailsView events: ItemUpdated vs ItemUpdating

Posted on 2012-03-18
5
590 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

821 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