473,503 Members | 1,813 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 12727
try

public static decimal ToDecimal(string value)
{
if (value == null || value.Length == 0)
return 0;
if (value == null)
throw new ArgumentNullException("value");
return Decimal.Parse(value.Replace(" ", ""), NumberStyles.AllowThousands |
NumberStyles.AllowDecimalPoint | NumberStyles.AllowCurrencySymbol,
CultureInfo.CurrentCulture);
}

--
Misbah Arefin
https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
"je**********@gmail.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...@discussions.microsoft.comwrote:
try

public static decimal ToDecimal(string value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullException("value");
* return Decimal.Parse(value.Replace(" ", ""), NumberStyles.AllowThousands |
NumberStyles.AllowDecimalPoint | NumberStyles.AllowCurrencySymbol,
CultureInfo.CurrentCulture);

}

--
Misbah Arefinhttps://mcp.support.microsoft.com/profile/MISBAH.AREFINhttp://www.linkedin.com/in/misbaharefin

"jehugalea...@gmail.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...@discussions.microsoft.comwrote:
try

public static decimal ToDecimal(string value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullException("value");
* return Decimal.Parse(value.Replace(" ", ""), NumberStyles.AllowThousands |
NumberStyles.AllowDecimalPoint | NumberStyles.AllowCurrencySymbol,
CultureInfo.CurrentCulture);

}

--
Misbah Arefinhttps://mcp.support.microsoft.com/profile/MISBAH.AREFINhttp://www.linkedin.com/in/misbaharefin

"jehugalea...@gmail.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...@discussions.microsoft.comwrote:
try

public static decimal ToDecimal(string value)
{
* if (value == null || value.Length == 0)
* * return 0;
* if (value == null)
* * throw new ArgumentNullException("value");
* return Decimal.Parse(value.Replace(" ", ""), NumberStyles.AllowThousands |
NumberStyles.AllowDecimalPoint | NumberStyles.AllowCurrencySymbol,
CultureInfo.CurrentCulture);

}

--
Misbah Arefinhttps://mcp.support.microsoft.com/profile/MISBAH.AREFINhttp://www.linkedin.com/in/misbaharefin

"jehugalea...@gmail.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
2931
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...
14
4283
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...
9
10391
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...
6
3822
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...
2
1295
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...
3
3071
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...
0
2124
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...
7
3427
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,...
6
4574
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...
0
7086
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
7330
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...
1
6991
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...
0
7460
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...
1
5014
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...
0
4672
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...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.