Right align not working in Datagrid

T

tshad

I can't seem to get my cells in my Datagrid to right justify for my money
fields.

I have set up my template tag as:

<asp:TemplateColumn Visible="true" HeaderText="Unit Price:"
ItemStyle-Width="75px" ItemStyle-HorizontalAlign="right"
ItemStyle-VerticalAlign="Top">


But it doesn't seem to work.

Why is that?

Thanks,

Tom
 
G

Guest

Try this.

<asp:TemplateColumn SortExpression="UnitPrice" HeaderText="UnitPrice">
<ItemStyle Wrap="False" HorizontalAlign="Right"></ItemStyle>
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.UnitPrice") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.UnitPrice") %>'>
</asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>

This worked for me.
 
T

tshad

Kiran Kumar Pinjala said:
Try this.

I did and it didn't work. But I found out why.

I have a statement in my styles sheet that has the following:

td {
empty-cells: show;
text-align:left;
}

I don't remember why I did this - I assume it was because of a problem I was
having with one of my tables.

But why wouldn't the Grid property override this?

The resulting code that the grid turns into is:

<td nowrap="nowrap" align="Right" style="width:90px;">
<span id="JobPostingGrid__ctl3_Balance">0</span>
</td>

So why didn't the align="Right" override the text-align:left?

Thanks,

Tom
 

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

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top