473,804 Members | 3,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculated value on textChanged event can't be updated to database

14 New Member
I have invoice form bound to a bindingsource and bindingnavigato r. In the form I have unit price, quantity and total textboxes. The total textbox text property is set to total.text = quantity.text * unitprice.text in the textChanged event of both quantity and unitprice text boxes. The result is displayed in the total textbox. But when i hit save button on the bindingnavigato r it is set to null and not saved to database.

The code on save button is
bindingsource.e ndEdit()
bindingsource.u pdate()
When I used msgbox to see the value of total textbox before bindingsource.e ndEdit() it is the correct value. but after the code bindingsource.e ndEdit() it is null. I checked the databinding property and it is correct. What is the problem.
Jan 14 '10 #1
4 2713
tlhintoq
3,525 Recognized Expert Specialist
total.text = quantity.text * unitprice.text
You can't apply math operations to text. You need to convert the text to some flavor of numbers first, whether it be floats, ints or decimals. Otherwise you might as be trying to perform total.text = "Fred" * "Wilma" which will not equal "Pebbles".
Jan 14 '10 #2
ashukite
14 New Member
the text box doesn't accept text. it is validated to accept numeric values only. Besides I tried this
total.text = convert.todecim al(quantity.tex t * unitprice.text) and the result I get on the msgbox is correct result. This is not the case.
Jan 14 '10 #3
ashukite
14 New Member
i didn't solve this problem. but i deleted the total field from my databse because it is a calculated value. I added a column to my dataset and make its value an expression.
Jan 14 '10 #4
tlhintoq
3,525 Recognized Expert Specialist
the text box doesn't accept text. it is validated to accept numeric values only. Besides I tried this
total.text = convert.todecim al(quantity.tex t * unitprice.text) and the result I get on the msgbox is correct result. This is not the case
The fact that you limit the incoming text to just numbers doesn't change the fact that the .Text value of a textbox is not an numeric value but a string.
You have to convert each value to a decimal *THEN* you can multiply those numbers.
Expand|Select|Wrap|Line Numbers
  1. decimal NewValue = Convert.ToDecimal(quantity.text) * Convert.ToDecimal(unitprice.Text);
Jan 15 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2933
by: Fabrício de Novaes Kucinskis | last post by:
Hi all, I have a combobox control, in wich I put an autocomplete code. This code is in the TextChanged event, but when this event fires, the Text property isn't updated yet. For example, if the Text property is "Foo" and I press the letter "d", the Text property when the TextChanged event runs is "Foo". Only after the TextChanged event be processed, the KeyDown, KeyUp and KeyPress events fires and update the Text property.
0
325
by: AndyDunning | last post by:
Following the initial load of data into bound controls as my form loads , I want to detect when a user have changed the value of one of the Combo or text box fields etc This will allow me to test the bDataChanged variable and warn the user that data has changed if they attempt to close the screen without saving. The problem I have is that I can't reliably set bDataChanged to False immediatly after the Initial load of the form as the...
3
5331
by: Jeremy Weiss | last post by:
I've got a temp table that contains the fields: amountowed, amountpaid, and balanced. I've got a form that shows this information and I've set it up so that when the amountpaid field is changed it subtracts the amountpaid from the amountowed and display's it in the balanced field. Unfortunately it doesn't save what is displayed back to the table. It does, however, save the changes to the amount paid field. I'm assuming my problem is...
1
2185
by: douh | last post by:
I know that this is not the way, however I need to save certian calculated values so that they do not change over time, ie. new tax rates etc. This is for an invoice header and invoice subform. I have a form myheader and mysub that are linked via a invoice number. mysub calculates qty * list = extprice. I am summing these into a sum_ext field in mysub footer. I need to have this value updated into the myheader invsubtot. I have tried many...
4
7120
by: Francesco | last post by:
Hi all, I am trying to make a UserControl with a TextBox in it. I have to publish the TextChanged event of the inner TextBox, but I have some trouble. If I declare : public event EventHandler TextChanged; I get a compiler error saying that TextChanged is already declared and I have to use : public new event EventHandler TextChanged;
1
4550
by: Samuel Chan | last post by:
I used the textchanged event of textbox and set the autopostback property to true. The textchanged event should fire when the content of the textbox is changed and user tab out of the textbox control. However, textchanged event fires whenever there is a postback, even when I click a button that send postback. Can anybody tell we what change I should make so that textchanged event only fire when the content is changed?
8
19546
by: Dan Keeley | last post by:
Hi, I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore... Dim Cmd As OleDbCommand = New OleDbCommand("Select AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value.ToString, conn)
1
1926
by: Manish | last post by:
Hello Everyone I am having weird problem in my datagrid bounded to datatable. My datatable is populated from SQLServer database. DataGrid has Calculated column Week% and Calculated record, SPLH. An example of datagrid is Category Amount Week% Revenue 200 Cost 60 30 Hours 100
0
1247
by: jarrett.roberts | last post by:
I have created a webform that allows the user to complete the form in three steps and allows a back and next button to allow easy navigation between these different forms. If they go back, I save the information that they had previously input. The problem I have run into, however, is that if a user decides to change their original values (in TextBoxes), the value is not updated when the "Next" (i.e. Submit) Button is pressed. I have...
0
9576
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
10567
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...
0
10323
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10310
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
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5515
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4291
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
3
2983
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.