473,385 Members | 1,347 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,385 software developers and data experts.

DataBinding Validation Question...

I've hooked up a TextBox's Text property with the property of a class.
However, when invalid data is entered, the data binding updates the object
immediately. Is there anyway to prevent this from happening? Or should I
just re-assign the value to the object directly in this case?
Thanks,

Michael
Nov 15 '05 #1
3 4606
Michael,

Have you tried to hook up to the Validate event to prevent the value
from being written? You should be able to cancel the action when the
Validate event is fired and prevent the data binding.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Michael" <Mi*************@Marconi.com> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
I've hooked up a TextBox's Text property with the property of a class.
However, when invalid data is entered, the data binding updates the object
immediately. Is there anyway to prevent this from happening? Or should I
just re-assign the value to the object directly in this case?
Thanks,

Michael

Nov 15 '05 #2

Hi Michael,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you do simple databinding with textbox's Text
propety. But the changed value will immediately update the source
datasource without validate, so you want to validate the data before change
the datasource.

================================================== ==
Based on my experience, you may use TextBox.Validating event to hook into
the update process.

The Validating event takes a CancelEventArgs, which has one property:
Canel. You can check the updating value in the textbox and if the data is
invalid just set CancelEventArgs.Canel to true. This will prevent the
source from updating.

I have made a test project and it works well.

================================================== ==
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #3

Hi Michael,

Does our reply resolve your problem?
If you still have any concern, please feel free to tell me, I will work
with you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4

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

Similar topics

4
by: Jason S | last post by:
I haven't been able to find a clear answer to this and I'm hoping someone could enlighten me. As pertains to databinding a control in a repeating fashion(datagrid, repeater, etc.) what event...
4
by: dtblankenship | last post by:
Hello everyone, I know this question has been asked many times in the forums, and after spending a few days reading, I am still confused as to the answer. I have a ListBox (lstBox),...
1
by: Charlie | last post by:
Hi: I'm creating some composite custom server controls that combine user interface element and a validation control. One such control combines a dropdownlist and required field validator. The...
5
by: Stewart | last post by:
Pressing a Save Button on a Toolbar will not bind or validate the last value entered in a text box. I have found that when clicking on the Toolbar the focus in the binded text box does not leave. ...
1
by: Heather Crow | last post by:
I have a VS.NET 2003 Visual Basic form which keeps hanging. It does not appear to matter what textbox I am on. When trying to edit the field I cannot move focus from this field to another. Clicking...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
7
by: Vlado Jasovic | last post by:
Hello, I'm using typed dataset for databinding to windows controls and I'm having some problems. I'm trying to move all business logic to datatable column_changing events and the problem that...
3
by: Peter | last post by:
Hi! I am having some very strange behavior with my databound controls. It's taken a long time to isolate exactly what is provoking the problem, but I'm still leagues away from solving it. I...
0
by: sammartin | last post by:
Hi, I've got a question which I'm hoping has a simple answer. I have a series of control bound to an underlying DataTable. The databinding are setup to update the data source on validation....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.