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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jehugaleahsa@gmail.com

    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
  • =?Utf-8?B?TWlzYmFoIEFyZWZpbg==?=

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

    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




    "jehugaleahsa@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
    >

    Comment

    • jehugaleahsa@gmail.com

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

      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.

      Comment

      • jehugaleahsa@gmail.com

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

        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.

        Comment

        • jehugaleahsa@gmail.com

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

          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.

          Comment

          Working...