Data Formatting Expression for datagrid

Discussion in 'ASP .Net' started by hope, Aug 25, 2005.

  1. hope

    hope Guest

    Hi,
    How can I format a string field using Data Formatting Expression property in
    datagrid?
    For example: format last name from BROWN to Brown.
    Thanks
     
    hope, Aug 25, 2005
    #1
    1. Advertising

  2. hope

    tom pester Guest

    Can you paste the line you use to display the name (there are 100's of ways
    of doing this).

    The string class has a method toUpper...

    Cheers,
    Tom Pester

    > Hi,
    > How can I format a string field using Data Formatting Expression
    > property in
    > datagrid?
    > For example: format last name from BROWN to Brown.
    > Thank
     
    tom pester, Aug 25, 2005
    #2
    1. Advertising

  3. Hi Hope,

    Welcome to ASP.NET newsgroup.
    As for the data formatting in DataGrid question, I think Tom's suggestion
    is reasonable since we could have multi means to display the databiding
    expression and the way we have to adjust it depends on the way to bind it.
    So how are you binding the string within datagrid curently? Generally we
    can adjust the databinding string directly in the aspx's inline databinding
    expression or use a helper function to do the formatting. Please feel free
    to post here if you have any further concerns.

    Thanks & Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)




    --------------------
    | Message-ID: <>
    | From: tom pester <>
    | Subject: Re: Data Formatting Expression for datagrid
    | References: <##>
    | MIME-Version: 1.0
    | Content-Transfer-Encoding: 8bit
    | Content-Type: text/plain; charset=iso-8859-1; format=flowed
    | X-Newsreader: JetBrains Omea Pro 661.1
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | Date: Thu, 25 Aug 2005 14:40:49 -0700
    | NNTP-Posting-Host: d51a4b60e.access.telenet.be 81.164.182.14
    | Lines: 1
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:120377
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    |
    | Can you paste the line you use to display the name (there are 100's of
    ways
    | of doing this).
    |
    | The string class has a method toUpper...
    |
    | Cheers,
    | Tom Pester
    |
    | > Hi,
    | > How can I format a string field using Data Formatting Expression
    | > property in
    | > datagrid?
    | > For example: format last name from BROWN to Brown.
    | > Thanks

    |
    |
     
    Steven Cheng[MSFT], Aug 26, 2005
    #3
  4. hope

    hope Guest

    Thank you for your answers.

    I was seeking a lazy way of formatting string data directly in the data
    formatting expression property of datagrid without either writing my own
    format type nor manipulate data while retrieving.

    I would like to take advantage of asp.net if there is a way to format string
    data that is similar to datetime formatting {0:yy-MM-dd}, say, using the
    syntax something like {0:Aa*} ?

    My datagrid is binding to a dataset which was returned by a stored
    procedure. The raw data looks like this:
    BROWN (All upper case)
    jackson (All lower case)
    Ford (the right format)

    What I really want is to display them consistently in datagrid:
    Brown
    Jackson
    Ford

    Thanks.





    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Hope,
    >
    > Welcome to ASP.NET newsgroup.
    > As for the data formatting in DataGrid question, I think Tom's suggestion
    > is reasonable since we could have multi means to display the databiding
    > expression and the way we have to adjust it depends on the way to bind it.
    > So how are you binding the string within datagrid curently? Generally we
    > can adjust the databinding string directly in the aspx's inline

    databinding
    > expression or use a helper function to do the formatting. Please feel

    free
    > to post here if you have any further concerns.
    >
    > Thanks & Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    >
    >
    >
    > --------------------
    > | Message-ID: <>
    > | From: tom pester <>
    > | Subject: Re: Data Formatting Expression for datagrid
    > | References: <##>
    > | MIME-Version: 1.0
    > | Content-Transfer-Encoding: 8bit
    > | Content-Type: text/plain; charset=iso-8859-1; format=flowed
    > | X-Newsreader: JetBrains Omea Pro 661.1
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet
    > | Date: Thu, 25 Aug 2005 14:40:49 -0700
    > | NNTP-Posting-Host: d51a4b60e.access.telenet.be 81.164.182.14
    > | Lines: 1
    > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
    > | Xref: TK2MSFTNGXA01.phx.gbl
    > microsoft.public.dotnet.framework.aspnet:120377
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    > |
    > |
    > | Can you paste the line you use to display the name (there are 100's of
    > ways
    > | of doing this).
    > |
    > | The string class has a method toUpper...
    > |
    > | Cheers,
    > | Tom Pester
    > |
    > | > Hi,
    > | > How can I format a string field using Data Formatting Expression
    > | > property in
    > | > datagrid?
    > | > For example: format last name from BROWN to Brown.
    > | > Thanks
    >
    > |
    > |
    >
     
    hope, Aug 26, 2005
    #4
  5. Thanks for your followup Hope,

    Yes, I agree with you that it's better to do the formatting work at
    rendering time rather than the data retrieving time, that' why we generally
    suggest use databinding expression to embeded some formatting operation.
    For your scenario, since there hasn't any direct keyword or format
    provider, the most convenient means would be write a custom helper function
    which translate the string value from the original value to our expected
    value. For example, we can define a protected function in page class or a
    public static funciton in a helper class and reference them in our
    datagrid's databinding expression like:

    <%# Translate(DataBinder.Eval(Container.DataItem,"name")) %>

    Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | From: "hope" <>
    | References: <##>
    <>
    <>
    | Subject: Re: Data Formatting Expression for datagrid
    | Date: Fri, 26 Aug 2005 10:35:34 -0400
    | Lines: 94
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    | Message-ID: <#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: newman.ncua.gov 207.15.63.4
    | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
    | Xref: TK2MSFTNGXA01.phx.gbl
    microsoft.public.dotnet.framework.aspnet:120497
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Thank you for your answers.
    |
    | I was seeking a lazy way of formatting string data directly in the data
    | formatting expression property of datagrid without either writing my own
    | format type nor manipulate data while retrieving.
    |
    | I would like to take advantage of asp.net if there is a way to format
    string
    | data that is similar to datetime formatting {0:yy-MM-dd}, say, using the
    | syntax something like {0:Aa*} ?
    |
    | My datagrid is binding to a dataset which was returned by a stored
    | procedure. The raw data looks like this:
    | BROWN (All upper case)
    | jackson (All lower case)
    | Ford (the right format)
    |
    | What I really want is to display them consistently in datagrid:
    | Brown
    | Jackson
    | Ford
    |
    | Thanks.
    |
    |
    |
    |
    |
    | "Steven Cheng[MSFT]" <> wrote in message
    | news:...
    | > Hi Hope,
    | >
    | > Welcome to ASP.NET newsgroup.
    | > As for the data formatting in DataGrid question, I think Tom's
    suggestion
    | > is reasonable since we could have multi means to display the databiding
    | > expression and the way we have to adjust it depends on the way to bind
    it.
    | > So how are you binding the string within datagrid curently? Generally we
    | > can adjust the databinding string directly in the aspx's inline
    | databinding
    | > expression or use a helper function to do the formatting. Please feel
    | free
    | > to post here if you have any further concerns.
    | >
    | > Thanks & Regards,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! www.microsoft.com/security
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | >
    | >
    | >
    | >
    | > --------------------
    | > | Message-ID: <>
    | > | From: tom pester <>
    | > | Subject: Re: Data Formatting Expression for datagrid
    | > | References: <##>
    | > | MIME-Version: 1.0
    | > | Content-Transfer-Encoding: 8bit
    | > | Content-Type: text/plain; charset=iso-8859-1; format=flowed
    | > | X-Newsreader: JetBrains Omea Pro 661.1
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | > | Date: Thu, 25 Aug 2005 14:40:49 -0700
    | > | NNTP-Posting-Host: d51a4b60e.access.telenet.be 81.164.182.14
    | > | Lines: 1
    | > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15.phx.gbl
    | > | Xref: TK2MSFTNGXA01.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet:120377
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | > |
    | > |
    | > | Can you paste the line you use to display the name (there are 100's of
    | > ways
    | > | of doing this).
    | > |
    | > | The string class has a method toUpper...
    | > |
    | > | Cheers,
    | > | Tom Pester
    | > |
    | > | > Hi,
    | > | > How can I format a string field using Data Formatting Expression
    | > | > property in
    | > | > datagrid?
    | > | > For example: format last name from BROWN to Brown.
    | > | > Thanks
    | >
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Aug 29, 2005
    #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. Sonali.NET[MVP]
    Replies:
    2
    Views:
    24,103
    TimDay
    Jul 30, 2006
  2. Alex
    Replies:
    0
    Views:
    424
  3. Volodymyr Lozovoy
    Replies:
    7
    Views:
    4,517
    Volodymyr Lozovoy
    Dec 9, 2004
  4. Replies:
    1
    Views:
    2,759
    Scott Allen
    May 30, 2005
  5. Richard Roche

    datagrid-changing data formatting expression at runtime

    Richard Roche, Oct 5, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    174
    Richard Roche
    Oct 5, 2005
Loading...

Share This Page