Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DetailsView events: ItemUpdated vs ItemUpdating

Posted on 2012-03-18
5
Medium Priority
?
632 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 45

Accepted Solution

by:
AndyAinscow earned 1000 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 1000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

610 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