datagrid : change the string formatting expression

Discussion in 'ASP .Net' started by Franck, Nov 3, 2005.

  1. Franck

    Franck Guest

    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
    Franck, Nov 3, 2005
    #1
    1. Advertising

  2. 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
    Emil Christopher Melar, Nov 3, 2005
    #2
    1. Advertising

  3. 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
    Emil Christopher Melar, Nov 3, 2005
    #3
  4. 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
    Emil Christopher Melar, Nov 3, 2005
    #4
    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,016
    TimDay
    Jul 30, 2006
  2. Alex
    Replies:
    0
    Views:
    415
  3. Adem
    Replies:
    42
    Views:
    2,792
    James Kuyper
    Nov 4, 2008
  4. Adem
    Replies:
    45
    Views:
    1,750
    James Kuyper
    Nov 4, 2008
  5. Franck

    datagrid : change the string formatting expression

    Franck, Nov 3, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    118
    Elton Wang
    Nov 3, 2005
Loading...

Share This Page