473,651 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP .NET Binding with Format {0:N0} is one way only

Hello:

I am working on an ASP .NET page and I have a integral value being
bound to a textbox.

I have it formatted with {0:N0} so that I get commas, but not decimal
places. When I go to update, I get an 'Input String not in the correct
format' error. I am not sure why it is okay for interface to correctly
display my data, but then not be able to update.

What is the fix?

Thanks,
Travis
Feb 26 '08 #1
4 12733
try

public static decimal ToDecimal(strin g value)
{
if (value == null || value.Length == 0)
return 0;
if (value == null)
throw new ArgumentNullExc eption("value") ;
return Decimal.Parse(v alue.Replace(" ", ""), NumberStyles.Al lowThousands |
NumberStyles.Al lowDecimalPoint | NumberStyles.Al lowCurrencySymb ol,
CultureInfo.Cur rentCulture);
}

--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
"je**********@g mail.com" wrote:
Hello:

I am working on an ASP .NET page and I have a integral value being
bound to a textbox.

I have it formatted with {0:N0} so that I get commas, but not decimal
places. When I go to update, I get an 'Input String not in the correct
format' error. I am not sure why it is okay for interface to correctly
display my data, but then not be able to update.

What is the fix?

Thanks,
Travis
Feb 27 '08 #2
On Feb 27, 4:09*am, Misbah Arefin
<MisbahAre...@d iscussions.micr osoft.comwrote:
try

public static decimal ToDecimal(strin g value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullExc eption("value") ;
* return Decimal.Parse(v alue.Replace(" ", ""), NumberStyles.Al lowThousands |
NumberStyles.Al lowDecimalPoint | NumberStyles.Al lowCurrencySymb ol,
CultureInfo.Cur rentCulture);

}

--
Misbah Arefinhttps://mcp.support.mic rosoft.com/profile/MISBAH.AREFINht tp://www.linkedin.co m/in/misbaharefin

"jehugalea...@g mail.com" wrote:
Hello:
I am working on an ASP .NET page and I have a integral value being
bound to a textbox.
I have it formatted with {0:N0} so that I get commas, but not decimal
places. When I go to update, I get an 'Input String not in the correct
format' error. I am not sure why it is okay for interface to correctly
display my data, but then not be able to update.
What is the fix?
Thanks,
Travis- Hide quoted text -

- Show quoted text -
That comes with too much work for something that should be built in.
Feb 27 '08 #3
On Feb 27, 4:09*am, Misbah Arefin
<MisbahAre...@d iscussions.micr osoft.comwrote:
try

public static decimal ToDecimal(strin g value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullExc eption("value") ;
* return Decimal.Parse(v alue.Replace(" ", ""), NumberStyles.Al lowThousands |
NumberStyles.Al lowDecimalPoint | NumberStyles.Al lowCurrencySymb ol,
CultureInfo.Cur rentCulture);

}

--
Misbah Arefinhttps://mcp.support.mic rosoft.com/profile/MISBAH.AREFINht tp://www.linkedin.co m/in/misbaharefin

"jehugalea...@g mail.com" wrote:
Hello:
I am working on an ASP .NET page and I have a integral value being
bound to a textbox.
I have it formatted with {0:N0} so that I get commas, but not decimal
places. When I go to update, I get an 'Input String not in the correct
format' error. I am not sure why it is okay for interface to correctly
display my data, but then not be able to update.
What is the fix?
Thanks,
Travis- Hide quoted text -

- Show quoted text -
I did what you said with the FormView and GridView Updating and
Inserting event handlers. I'm not too happy about it. I'm going to go
boil my head.
Feb 27 '08 #4
On Feb 27, 4:09*am, Misbah Arefin
<MisbahAre...@d iscussions.micr osoft.comwrote:
try

public static decimal ToDecimal(strin g value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullExc eption("value") ;
* return Decimal.Parse(v alue.Replace(" ", ""), NumberStyles.Al lowThousands |
NumberStyles.Al lowDecimalPoint | NumberStyles.Al lowCurrencySymb ol,
CultureInfo.Cur rentCulture);

}

--
Misbah Arefinhttps://mcp.support.mic rosoft.com/profile/MISBAH.AREFINht tp://www.linkedin.co m/in/misbaharefin

"jehugalea...@g mail.com" wrote:
Hello:
I am working on an ASP .NET page and I have a integral value being
bound to a textbox.
I have it formatted with {0:N0} so that I get commas, but not decimal
places. When I go to update, I get an 'Input String not in the correct
format' error. I am not sure why it is okay for interface to correctly
display my data, but then not be able to update.
What is the fix?
Thanks,
Travis- Hide quoted text -

- Show quoted text -
Oh, and thanks.
Feb 27 '08 #5

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

Similar topics

3
2944
by: Jesse | last post by:
Hi All, I've been working on a form that has several bound controls that all link to one table in a dataset. In the table, there is a column for the filename of jpeg images related to each record. I have a combobox which displays the key for each record so that the user can select an item and all the other controls update. So far i have the combobox, a label and a textbox all bound and working correctly when a user selects an item. ...
14
4299
by: Composer | last post by:
I've read many postings about the problem of Access.References.IsBroken and the consensus seems to be that late binding is the cure-all. I have a very complex Access application that needs hundreds of lines of code to format a Word document in a very specific way. Because my clients have various versions of Word, the problem of broken references comes up. I wish Microsoft had implemented a reasonable solution, so that VBA could do...
9
10413
by: Zlatko Matiæ | last post by:
I was reading about late binding, but I'm not completely sure what is to be done in order to adjust code to late binding... For example, I'm not sure if this is correct: early binding: Dim ws As DAO.Workspace Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim rs As DAO.Recordset
6
3830
by: Hutty | last post by:
I've looked around and have yet to find anything that would answer my question regarding formating a column in a datagrid. My grid looks like this as far as data" AMHQCON|51300.01|-3147 The first two columns are pretty much text column, but subsequent columns 1-12 are numerical. I'm trying to get the thousand separator to work. Any ideas?
2
1300
by: Tubs | last post by:
I am trying to use data binding to avoid having to write event handlers everywhere for my data transfer from controls to data source and all is working well except, i have a condition i would like to place on the value before i let it go through. I have built an expression evaluator to determine when something is valid versus invalid. My problem is that when i trap the format event of the data binding, i can get to the value before it...
3
3078
by: Slonocode | last post by:
I have some textboxes bound to an access db. I wanted to format the textboxes that displayed currency and date info so I did the following: Dim WithEvents oBidAmt As Binding oBidAmt = New Binding("Text", Me.Ds1, "Items.BidAmt") txtBidAmt.DataBindings.Add(oBidAmt) Private Sub oBidAmt_Format(ByVal sender As Object, ByVal e As System.Windows.Forms.ConvertEventArgs) Handles oBidAmt.Format
0
2140
by: manir | last post by:
Hi, It would really be of great help if you could suggest a solution for me. Program: I need to execute a stored procedure from an Oracle server through a C++ program using oci.h (Oracle Call Interface) libraries of C. #include <oci.h> #define FMT "DAY, MONTH DD, YYYY"
7
3440
by: Steve K | last post by:
First problem: I am specifying a format string for a Binding object like so: <code> Binding binding = new Binding("Text", item.EOBRemittance, "AmountAllowed", true, DataSourceUpdateMode.Never, 0, "{0} Selected Pages");
6
4588
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this works fine: Text='<%# Eval("Price", ApplicationContext.CurrencyFormat) %>'
0
8352
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
8275
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
8802
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
8697
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
8465
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
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
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...
0
5612
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();...
2
1587
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.