Newbie Gridview Problem when editing currencies

Discussion in 'ASP .Net Datagrid Control' started by AAJ, Sep 15, 2006.

  1. AAJ

    AAJ Guest

    Hi all

    I posted this last week in a different group but had no response. I wonder
    if any of you guys can help me.

    I have a gridview that displays a field as a currency i.e. £100.00, which is
    exactly what I want.

    When I edit the row, the edit box for the column shows £100.00. This is
    where the problem lies, if I save the record without deleting the currency
    sign first, it fails with a conversion error. Obviously this is causing a
    headache. I need the box to allow either £100.00 or just 100.00 and have it
    accept either, after all its just a decimal behind the scenes.

    does anyone know a way around it

    many thanks in advance

    Andy
    AAJ, Sep 15, 2006
    #1
    1. Advertising

  2. What's adding the currency symbol to the value?

    "AAJ" <a.a.com> wrote in message
    news:...
    > Hi all
    >
    > I posted this last week in a different group but had no response. I wonder
    > if any of you guys can help me.
    >
    > I have a gridview that displays a field as a currency i.e. £100.00, which
    > is exactly what I want.
    >
    > When I edit the row, the edit box for the column shows £100.00. This is
    > where the problem lies, if I save the record without deleting the currency
    > sign first, it fails with a conversion error. Obviously this is causing a
    > headache. I need the box to allow either £100.00 or just 100.00 and have
    > it accept either, after all its just a decimal behind the scenes.
    >
    > does anyone know a way around it
    >
    > many thanks in advance
    >
    > Andy
    >
    Ken Cox [Microsoft MVP], Sep 18, 2006
    #2
    1. Advertising

  3. AAJ

    AAJ Guest

    Hi Ken

    Its in the datagrid itsself

    I just used {0:c}in the data format string. This automatically carries
    through to the edit field template

    in the databinding of the edit field it has Bind("material_rate", "{0:C}")

    cheers

    Andy

    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:...
    > What's adding the currency symbol to the value?
    >
    > "AAJ" <a.a.com> wrote in message
    > news:...
    >> Hi all
    >>
    >> I posted this last week in a different group but had no response. I
    >> wonder if any of you guys can help me.
    >>
    >> I have a gridview that displays a field as a currency i.e. £100.00, which
    >> is exactly what I want.
    >>
    >> When I edit the row, the edit box for the column shows £100.00. This is
    >> where the problem lies, if I save the record without deleting the
    >> currency sign first, it fails with a conversion error. Obviously this is
    >> causing a headache. I need the box to allow either £100.00 or just 100.00
    >> and have it accept either, after all its just a decimal behind the
    >> scenes.
    >>
    >> does anyone know a way around it
    >>
    >> many thanks in advance
    >>
    >> Andy
    >>

    >
    >
    AAJ, Sep 18, 2006
    #3
  4. You could convert to template fields and then remove the ":C" from the
    edititem template.

    "AAJ" <a.a.com> wrote in message
    news:...
    > Hi Ken
    >
    > Its in the datagrid itsself
    >
    > I just used {0:c}in the data format string. This automatically carries
    > through to the edit field template
    >
    > in the databinding of the edit field it has Bind("material_rate", "{0:C}")
    >
    > cheers
    >
    > Andy
    >
    > "Ken Cox [Microsoft MVP]" <> wrote in
    > message news:...
    >> What's adding the currency symbol to the value?
    >>
    >> "AAJ" <a.a.com> wrote in message
    >> news:...
    >>> Hi all
    >>>
    >>> I posted this last week in a different group but had no response. I
    >>> wonder if any of you guys can help me.
    >>>
    >>> I have a gridview that displays a field as a currency i.e. £100.00,
    >>> which is exactly what I want.
    >>>
    >>> When I edit the row, the edit box for the column shows £100.00. This is
    >>> where the problem lies, if I save the record without deleting the
    >>> currency sign first, it fails with a conversion error. Obviously this is
    >>> causing a headache. I need the box to allow either £100.00 or just
    >>> 100.00 and have it accept either, after all its just a decimal behind
    >>> the scenes.
    >>>
    >>> does anyone know a way around it
    >>>
    >>> many thanks in advance
    >>>
    >>> Andy
    >>>

    >>
    >>

    >
    >
    Ken Cox [Microsoft MVP], Sep 18, 2006
    #4
  5. AAJ

    AAJ Guest

    Hi Ken

    many thanks, works a treat now - {0:c} when displaying, {0:F2} when editing

    cheers

    Andy



    "Ken Cox [Microsoft MVP]" <> wrote in message
    news:%...
    > You could convert to template fields and then remove the ":C" from the
    > edititem template.
    >
    > "AAJ" <a.a.com> wrote in message
    > news:...
    >> Hi Ken
    >>
    >> Its in the datagrid itsself
    >>
    >> I just used {0:c}in the data format string. This automatically carries
    >> through to the edit field template
    >>
    >> in the databinding of the edit field it has Bind("material_rate",
    >> "{0:C}")
    >>
    >> cheers
    >>
    >> Andy
    >>
    >> "Ken Cox [Microsoft MVP]" <> wrote in
    >> message news:...
    >>> What's adding the currency symbol to the value?
    >>>
    >>> "AAJ" <a.a.com> wrote in message
    >>> news:...
    >>>> Hi all
    >>>>
    >>>> I posted this last week in a different group but had no response. I
    >>>> wonder if any of you guys can help me.
    >>>>
    >>>> I have a gridview that displays a field as a currency i.e. £100.00,
    >>>> which is exactly what I want.
    >>>>
    >>>> When I edit the row, the edit box for the column shows £100.00. This is
    >>>> where the problem lies, if I save the record without deleting the
    >>>> currency sign first, it fails with a conversion error. Obviously this
    >>>> is causing a headache. I need the box to allow either £100.00 or just
    >>>> 100.00 and have it accept either, after all its just a decimal behind
    >>>> the scenes.
    >>>>
    >>>> does anyone know a way around it
    >>>>
    >>>> many thanks in advance
    >>>>
    >>>> Andy
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
    AAJ, Sep 19, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    333
  2. techy techno
    Replies:
    2
    Views:
    177
    Phil Donaldson
    Feb 17, 2004
  3. mark | r
    Replies:
    1
    Views:
    112
  4. dysfunctional
    Replies:
    5
    Views:
    117
    dysfunctional
    Apr 22, 2006
  5. eng.brain360

    A program that convert currencies

    eng.brain360, Apr 26, 2012, in forum: C Programming
    Replies:
    0
    Views:
    431
    eng.brain360
    Apr 26, 2012
Loading...

Share This Page