473,803 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4632
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.co m

"Michael" <Mi************ *@Marconi.com> wrote in message
news:eb******** ******@tk2msftn gp13.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.Validat ing 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
1301
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 would one handle to get a handle on things just BEFORE the data is bound. To be clearer, not controlling the formatting of the bound control(backcolor or what have you), but rather control the WAYor even IF the data is bound at all. For instance,...
4
4213
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), SqlConnection (sqlConnection), SqlDataAdapter (daLookupData), SqlDataAdapter (daData), DataSet (dsLookupData), and DataSet (dsData), all created via the IDE during design-time. Here is the design of my simple tables: (An example since I can't post my...
1
1129
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 problem is when I want to use it on a form, how do I get a reference to the dropdownlist contained within the control to call databind method? Also, if I call databind within server control, it works but viewstate doesn't work. Does any know of...
5
1847
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. Therefore in this case not saving the last entry when saving. I am able to use the following code to get round the updating of the object from the field value with this code before saving Private m_Record As Customer ....... Private Sub...
1
1644
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 buttons etc. does nothing and the focus remains with the field I had been editing. The text boxes are bound to a record in a SQL database.
9
2111
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 form, have the user fill it out then put the data into a class representing a data row and then use the OLEadaptor or OLECommands to update the database. My question is has anyone really used databinding in anything but the simpliest application...
7
2597
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 I'm having is when I change some other column, control value doesn't update immediately until I call endcurrentedit on bindingmanager which doesnt happen until user click update button.
3
1890
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 have a DataView which filters a DataSet. Bound to this dataview is a ListBox, via its DataSource property. The DisplayMember is the name property of the row. Simple enough so far?
0
1836
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. I have an event handler monitoring the ColumnChanged event on the DataTable, and in certain circumstances I update another column in the datatable.
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10542
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10289
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9119
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3795
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.