Solved

DetailsView events: ItemUpdated vs ItemUpdating

Posted on 2012-03-18
5
602 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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 …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

732 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