473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

FormView, ObjectDataSource and the evil binding

Hi All,
excuse me in advance for my not very perfect english. I need some help about
a problem with a FormView bounded to an ObjectDataSource. In practise I have
an ObjectDataSource that uses some BLL methods that implements the
optimistic concurrency by a TimeStamp field into the DB. So, when I execute
an insert, update or delete query if I receive 0 like return value from that
queries I understand that a concurrency problem is occurs so I will inform
the user.

The problem comes because, when I'm able to know that a concurrency error is
occurs is too late, because the only event of the FormView in wich I can
cancel the databind (by the Cancel property of the FormViewupdateEventArgs
object) is the ItemUpdating event that, unfortunatelly, occurs BEFORE the
Updated Event of the ObjectDataSource in wich I can check the concurrency
error. So, when a concurrency error occurs I can inform the user but I can't
avoid to reset the FormView with the new value stored into the DB, losting
all the new values entered by the user.

How can I solve this problem? Is there a method to cancel the automatic bind
on the FormView and force id only when I want?

Thanks a lot.

--
KaOne
http://thekaone.blogspot.com
-----------------------------------
Jun 18 '07 #1
3 8070
Hi KaOne,

From your description, you're using some custom BLL component class to
access database for query/updating. And you use Objectdatasource to connect
them with ASP.NETT 2.0 Formview control. However, since the update method
of BLL class will indicate concurrent update error as return value, it will
be too late to inform FormView not to change status, correct?

Based on my understanding, if your concurrent update error is not raised as
exception , but an normal return code, the FormView will treat the update
command as success and change the mode. I think you can have test on the
following things:

The FormView control has a "ModeChanging" event, you can add handler and
print some statement in it to see whether it occurs before your BLL
component class return update result. If you can get the update result
first, then you can mark a flag in a page variable or any other place. In
the Modechanging event, you can cancel the mode changing.

Also, another means is we manually do the update instead of using the
FormView's updating command(use another postback button that doesn't use
"Update" as command name), and only when the update succeed will we
manually call FormView's ChangeMode method to change the current mode. How
do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 19 '07 #2
Mentre era fermo al semaforo, Steven Cheng[MSFT] prese il suo portatile e
scrisse:
From your description, you're using some custom BLL component class to
access database for query/updating. And you use Objectdatasource to
connect them with ASP.NETT 2.0 Formview control. However, since the
update method of BLL class will indicate concurrent update error as
return value, it will be too late to inform FormView not to change
status, correct?
Hi Steven,
yes, this is correct. It is my scenario.
Based on my understanding, if your concurrent update error is not
raised as exception , but an normal return code, the FormView will
treat the update command as success and change the mode. I think you
can have test on the following things:
The problem "was" right that. It was a logic error. Now I have changed this
behavior using a DBConcurrencyException when the result of the UPDATE query
is 0, so the FormView can treat correctly the situation and I can cancel the
submit. In this manner the user don't lost their data.

Thanks a lot for your reply.

--
KaOne
http://thekaone.blogspot.com
-----------------------------------
Jun 19 '07 #3
Thanks for your reply KaOne,

I think your current implementation that manually throw out a exception
based on the logical error return value is reasonable. Glad that you've
found the solution on this.

If you need any further assistance later, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 20 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Islamegy® | last post by:
I'm use FormView for editing a photo gallery... I add FileUpload control to upload images to the Gallery. I'm binding my Formview to objectdatasource i tried upload images onItemInserting &...
1
by: Sean | last post by:
I have them working together just fine and update does make changes only I have one small problem. Changes made on the formview do not reflect on the grid on postback. I have to leave the page...
0
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control...
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
2
by: J055 | last post by:
Hi I have 2 user controls and 1 parent page. One user control contains a Gridview and the other a FormView. When the GridView row Select command is fired it bubbles an event to the parent page...
6
by: Chris | last post by:
I want do my insert to a database using a formview bound to an objectdatasource. I also want to upload a file. I'm quite new to and this is just test code but Is there any way I can pass the file...
5
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a...
1
by: Bresco | last post by:
I'm using ObjectDatasource in combination with a Formview. The ObjectDatasource is connected to a FormView. I have a business object property which I can't update through the normal binding...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.