Datagrid: aligning a template column?

Discussion in 'ASP .Net Web Controls' started by d[ - - ]b, May 18, 2004.

  1. d[ - - ]b

    d[ - - ]b Guest

    Hi,

    Is it possible to align a template column? Tried align, textalign and
    itemstyle (but I think that one is for the whole grid?), and nothing works.
    It's a simple datagrid, but one field is a dollar ($) value, so I've had to
    do a TemplateColumn so that I could make it have the '$'-sign and the
    decimal places, but it's aligned to the left which is kinda ugly. Any ideas
    how to change this column alone or another way to do this?

    Many thanks,
    Naomi
     
    d[ - - ]b, May 18, 2004
    #1
    1. Advertising

  2. > Is it possible to align a template column?

    Sure.

    <asp:TemplateColumn ItemStyle-HorizontalAlign="right">
    ...
    </asp:TemplateColumn>

    > It's a simple datagrid, but one field is a dollar ($) value, so I've had to
    > do a TemplateColumn so that I could make it have the '$'-sign and the
    > decimal places, but it's aligned to the left which is kinda ugly. Any ideas
    > how to change this column alone or another way to do this?


    You could use a BoundColumn for this with the DataFormatString set to
    {0:c} and the ItemStyle-HorizontalAlign set to right.

    You might find this article series on the DataGrid Web control helpful:
    http://aspnet.4guysfromrolla.com/articles/040502-1.aspx

    Happy Programming!

    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], May 18, 2004
    #2
    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. Dexter
    Replies:
    1
    Views:
    432
    Eliyahu Goldin
    Jan 18, 2005
  2. Ken Varn
    Replies:
    1
    Views:
    987
    Ken Varn
    Aug 19, 2005
  3. nemo
    Replies:
    1
    Views:
    4,754
    S. Justin Gengo
    Sep 16, 2005
  4. Vijaya

    Aligning the controls in the item template of the datagrid

    Vijaya, Dec 15, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    207
    Kelly Leahy
    Dec 18, 2003
  5. d[ - - ]b

    Datagrid: aligning a template column

    d[ - - ]b, May 18, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    147
    d[ - - ]b
    May 18, 2004
Loading...

Share This Page