Data Formatting Expression for datagrid

H

hope

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
 
T

tom pester

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
 
S

Steven Cheng[MSFT]

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: <[email protected]>
| From: tom pester <[email protected]>
| Subject: Re: Data Formatting Expression for datagrid
| References: <##[email protected]>
| 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

|
|
 
H

hope

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.
 
S

Steven Cheng[MSFT]

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" <[email protected]>
| References: <##[email protected]>
<[email protected]>
<[email protected]>
| 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: <#[email protected]>
| 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.
|
|
|
|
|
| | > 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: <[email protected]>
| > | From: tom pester <[email protected]>
| > | Subject: Re: Data Formatting Expression for datagrid
| > | References: <##[email protected]>
| > | 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
| >
| > |
| > |
| >
|
|
|
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top