Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > datagrid : change the string formatting expression

Reply
Thread Tools

datagrid : change the string formatting expression

 
 
Franck
Guest
Posts: n/a
 
      11-03-2005
hello,

i'm looking for code (C# preferably)
in order to change programmatically in a datagrid
the string formatting expression of one bound colum

thank you
 
Reply With Quote
 
 
 
 
Emil Christopher Melar
Guest
Posts: n/a
 
      11-03-2005
Franck wrote:
> hello,
>
> i'm looking for code (C# preferably)
> in order to change programmatically in a datagrid
> the string formatting expression of one bound colum
>
> thank you


Example:

<%# DataBinder.Eval(Container.DataItem, "MyDate", "{0:d}")%>

Will format the DateTime to display as short-date, ie dd.mm.yyyy or
other format based on the culture.

The third parameter is the format expression.

Go read MSDN.


--
Emil Christopher Melar
 
Reply With Quote
 
 
 
 
Emil Christopher Melar
Guest
Posts: n/a
 
      11-03-2005
Franck wrote:
> hello,
>
> i'm looking for code (C# preferably)
> in order to change programmatically in a datagrid
> the string formatting expression of one bound colum
>
> thank you


Sorry, Ignore my last post, I didn't read your post well enough.

Again, sorry.

--
Emil Christopher Melar
 
Reply With Quote
 
Emil Christopher Melar
Guest
Posts: n/a
 
      11-03-2005
Franck wrote:
> hello,
>
> i'm looking for code (C# preferably)
> in order to change programmatically in a datagrid
> the string formatting expression of one bound colum
>
> thank you


I do not have enough information.

The only solution that I can think of, is that you have to drop the
aspx-style binding to the column, and rather do this in ItemDataBound by
referencing the datasource from the e.Item.DataItem and reference a
control (literal or whatever) in the ItemTemplate instead.

Where do you want to change the format string, based on what criteria?

--
Emil Christopher Melar
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C Programming 45 11-04-2008 12:39 PM
Re: How to use formatting expression on DataGrid bound column. Sonali.NET[MVP] ASP .Net 2 07-30-2006 03:18 PM
datagrid : change the string formatting expression Franck ASP .Net Datagrid Control 1 11-03-2005 05:43 PM
Data formatting expression wanted for dataset bound datagrid column for href Alex ASP .Net 0 04-14-2004 04:03 PM



Advertisments