Datagrid: aligning a template column?

D

d[ - - ]b

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
 
S

Scott Mitchell [MVP]

Is it possible to align a template column?

Sure.

<asp:TemplateColumn ItemStyle-HorizontalAlign="right">
...
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
(e-mail address removed)
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
 

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

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,083
Members
48,773
Latest member
Kaybee

Latest Threads

Top