Datagrid column formatting

Discussion in 'ASP .Net Datagrid Control' started by Kelly, Apr 22, 2005.

  1. Kelly

    Kelly Guest

    Is it possible to set the column widths of a datagrid?

    This is driving me crazy, and I haven't found a solution yet. I'm pretty new
    to ASP.NET so there may be an easy way I'm just not aware of, however, I've
    Googled this until my eyes hurt and still haven't found a solution.

    Also, how would I set a few of my columns' format? (I have 3 date columns
    within the datagrid and I'd like to set the format to dd/mm/yyyy or
    something similar...)

    Any and all help would be appreciated!

    -Kelly
     
    Kelly, Apr 22, 2005
    #1
    1. Advertising

  2. Kelly

    Elton W Guest

    Hi

    You can use HeaderStyle-Width and ItemStyle-Width of
    column to set column width.

    To format date in a BoundColumn:
    DataFormatString="{0: MM/dd/yyyy}"

    To format date in a TemplateColumn:
    Text ='<%# DataBinder.Eval
    (Container.DataItem, "DateField", "{0: dd/MM/yyyy}")'

    HTH

    Elton Wang




    >-----Original Message-----
    >Is it possible to set the column widths of a datagrid?
    >
    >This is driving me crazy, and I haven't found a solution

    yet. I'm pretty new
    >to ASP.NET so there may be an easy way I'm just not aware

    of, however, I've
    >Googled this until my eyes hurt and still haven't found a

    solution.
    >
    >Also, how would I set a few of my columns' format? (I

    have 3 date columns
    >within the datagrid and I'd like to set the format to

    dd/mm/yyyy or
    >something similar...)
    >
    >Any and all help would be appreciated!
    >
    >-Kelly
    >
    >
    >.
    >
     
    Elton W, Apr 22, 2005
    #2
    1. Advertising

  3. Kelly

    Kelly Guest

    Thank you! I'll fiddle with this a bit. :)

    -Kelly

    "Elton W" <> wrote in message
    news:12ae01c5477d$c8450de0$...
    > Hi
    >
    > You can use HeaderStyle-Width and ItemStyle-Width of
    > column to set column width.
    >
    > To format date in a BoundColumn:
    > DataFormatString="{0: MM/dd/yyyy}"
    >
    > To format date in a TemplateColumn:
    > Text ='<%# DataBinder.Eval
    > (Container.DataItem, "DateField", "{0: dd/MM/yyyy}")'
    >
    > HTH
    >
    > Elton Wang
    >
    >
    >
    >
    > >-----Original Message-----
    > >Is it possible to set the column widths of a datagrid?
    > >
    > >This is driving me crazy, and I haven't found a solution

    > yet. I'm pretty new
    > >to ASP.NET so there may be an easy way I'm just not aware

    > of, however, I've
    > >Googled this until my eyes hurt and still haven't found a

    > solution.
    > >
    > >Also, how would I set a few of my columns' format? (I

    > have 3 date columns
    > >within the datagrid and I'd like to set the format to

    > dd/mm/yyyy or
    > >something similar...)
    > >
    > >Any and all help would be appreciated!
    > >
    > >-Kelly
    > >
    > >
    > >.
    > >
     
    Kelly, Apr 22, 2005
    #3
    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,085
    TimDay
    Jul 30, 2006
  2. Anatoly
    Replies:
    1
    Views:
    561
    Hrvoje Vrbanc
    Jul 15, 2003
  3. Alex
    Replies:
    0
    Views:
    423
  4. SStory
    Replies:
    7
    Views:
    333
    SStory
    Jun 25, 2004
  5. TJ

    Formatting the phone nos in the column in the datagrid

    TJ, May 13, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    122
    Elton W
    May 13, 2005
Loading...

Share This Page