Can't right justify datagrid fields

T

tshad

I have a datagrid that I cannot get to right justify a money amount (which
is just a label). No matter what I do - it still right justifies it.

<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right" >
<itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>

I tried 2 different ways:
ItemStyle-HorizontalAlign="right"
style="text-align:right"

This gives me the following results when I view source:

<td align="Right" valign="Middle" style="width:100px;">
<span id="DataGrid1__ctl3_JobBoardPriceDisplay"
style="text-align:right"><strong>$25.00</strong></span>
</td>

What else can I do to make this work?

Thanks,

Tom
 
G

Guest

Hi there,

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="lbl"/>
</ItemTemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateField>
</Columns>

hope this helps
 
T

tshad

Milosz Skalecki said:
Hi there,

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="lbl"/>
</ItemTemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateField>
</Columns>

That doesn't work either. It seems to be the same as what I have (except
mine is inside the asp:TemplateColumn tag).

<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right"
<itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateColumn>

Here is the result in my view source:

<td align="Right" valign="Middle" style="width:100px;">
<span id="DataGrid1__ctl4_JobBoardPriceDisplay">$1.00</span>
</td>

It creates the align="Right" in the td tag and seems to take out the
text-align:right completely as I assume that is because it is going to
create its own style from the ItemStyle... attributes.

But I assume that since there is nothing in the span statement - the align
doesn't seem to work.

Thanks,

Tom
 
G

Guest

Howdy,

It did work for me. Any chance there is a default style for a table cell
defined?

Regards
--
Milosz


tshad said:
Milosz Skalecki said:
Hi there,

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" ID="lbl"/>
</ItemTemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateField>
</Columns>

That doesn't work either. It seems to be the same as what I have (except
mine is inside the asp:TemplateColumn tag).

<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right" <itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateColumn>

Here is the result in my view source:

<td align="Right" valign="Middle" style="width:100px;">
<span id="DataGrid1__ctl4_JobBoardPriceDisplay">$1.00</span>
</td>

It creates the align="Right" in the td tag and seems to take out the
text-align:right completely as I assume that is because it is going to
create its own style from the ItemStyle... attributes.

But I assume that since there is nothing in the span statement - the align
doesn't seem to work.

Thanks,

Tom
 
T

tshad

Milosz Skalecki said:
Howdy,

It did work for me. Any chance there is a default style for a table cell
defined?

Here is the datagrid statement:

<asp:DataGrid
Visible=true
AllowSorting="false"
AutoGenerateColumns="false"
CellPadding="0"
CellSpacing="0"
ID="DataGrid1"
runat="server"
BorderWidth="0"
ShowFooter="false"
ShowHeader="true"
GridLines="None"
Width="245px" Style="border-collapse:collapse;padding-left:2px">
<columns>
<asp:TemplateColumn Visible="true" ItemStyle-HorizontalAlign="center"
ItemStyle-Width="25px">
<itemtemplate>
<asp:CheckBox ID="Choice" OnCheckedChanged="Handle3rdPartyPost_Click"
AutoPostBack="true" runat="server" />
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="true" ItemStyle-Width="120px" HeaderText="3rd
Party" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" >
<itemtemplate>
<asp:Label ID="JobBoardName" Text='<%# Container.DataItem("Name")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" itemStyle-Width="80px"
ItemStyle-VerticalAlign="middle" >
<itemtemplate>
<asp:Label ID="JobBoardPrice" Text='<%# Container.DataItem("Price")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right" >
<itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" ItemStyle-Font-Bold="true"
ItemStyle-Width="165px" ItemStyle-VerticalAlign="middle">
<itemtemplate>
<asp:TextBox ID="AccountNumber" Text='<%#
Container.DataItem("AccountNumber")%>' Enabled="true" Columns="15"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="JobBoardID" Text='<%# Container.DataItem("JobBoardID")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" >
<itemtemplate>
<asp:TextBox ID="RecordState" Visible="false" Columns="10"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>
<asp:Label ID="ErrorMessage2" ForeColor="red" runat="server"/>

The important cell would be the ID=JobBoardPriceDisplay.

Thanks,

Tom
 
G

Guest

Howdy,

<asp:TemplateColumn Visible="true" HeaderText="Amount Per Job"
HeaderStyle-Font-Bold="true">
<ItemTemplate>
<asp:Label ID="JobBoardPriceDisplay" runat="server" />
</ItemTemplate>
<ItemStyle HorizontalAlign="right"
VerticalAlign="middle" Width="100px"/>

does the job. If it doesn't, you applied default css formatting for table
somewhere on the page or stylesheet.

regards
--
Milosz


tshad said:
Milosz Skalecki said:
Howdy,

It did work for me. Any chance there is a default style for a table cell
defined?

Here is the datagrid statement:

<asp:DataGrid
Visible=true
AllowSorting="false"
AutoGenerateColumns="false"
CellPadding="0"
CellSpacing="0"
ID="DataGrid1"
runat="server"
BorderWidth="0"
ShowFooter="false"
ShowHeader="true"
GridLines="None"
Width="245px" Style="border-collapse:collapse;padding-left:2px">
<columns>
<asp:TemplateColumn Visible="true" ItemStyle-HorizontalAlign="center"
ItemStyle-Width="25px">
<itemtemplate>
<asp:CheckBox ID="Choice" OnCheckedChanged="Handle3rdPartyPost_Click"
AutoPostBack="true" runat="server" />
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="true" ItemStyle-Width="120px" HeaderText="3rd
Party" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" >
<itemtemplate>
<asp:Label ID="JobBoardName" Text='<%# Container.DataItem("Name")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" itemStyle-Width="80px"
ItemStyle-VerticalAlign="middle" >
<itemtemplate>
<asp:Label ID="JobBoardPrice" Text='<%# Container.DataItem("Price")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="true" itemStyle-Width="100px"
HeaderText="Amount Per Job" HeaderStyle-Font-Bold="true"
ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right" >
<itemtemplate>
<asp:Label ID="JobBoardPriceDisplay" style="text-align:right"
runat="server"/>
</itemtemplate>
<ItemStyle HorizontalAlign="right"/>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" ItemStyle-Font-Bold="true"
ItemStyle-Width="165px" ItemStyle-VerticalAlign="middle">
<itemtemplate>
<asp:TextBox ID="AccountNumber" Text='<%#
Container.DataItem("AccountNumber")%>' Enabled="true" Columns="15"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false">
<itemtemplate>
<asp:Label ID="JobBoardID" Text='<%# Container.DataItem("JobBoardID")%>'
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="false" >
<itemtemplate>
<asp:TextBox ID="RecordState" Visible="false" Columns="10"
runat="server"/>
</itemtemplate>
</asp:TemplateColumn>
</columns>
</asp:DataGrid>
<asp:Label ID="ErrorMessage2" ForeColor="red" runat="server"/>

The important cell would be the ID=JobBoardPriceDisplay.

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top