Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

Can't right justify datagrid fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tshad - 22 Jun 2007 00:46 GMT
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
Milosz Skalecki [MCAD] - 22 Jun 2007 11:01 GMT
Hi there,

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

hope this helps
Signature

Milosz

> 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.
[quoted text clipped - 24 lines]
>
> Tom
tshad - 22 Jun 2007 19:54 GMT
> Hi there,
>
[quoted text clipped - 6 lines]
> </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

> hope this helps
>
[quoted text clipped - 27 lines]
>>
>> Tom
Milosz Skalecki [MCAD] - 22 Jun 2007 22:22 GMT
Howdy,

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

Regards
Signature

Milosz

> > Hi there,
> >
[quoted text clipped - 69 lines]
> >>
> >> Tom
tshad - 23 Jun 2007 00:27 GMT
> 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

> Regards
>
[quoted text clipped - 73 lines]
>> >>
>> >> Tom
Milosz Skalecki [MCAD] - 24 Jun 2007 21:21 GMT
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
Signature

Milosz

> > Howdy,
> >
[quoted text clipped - 155 lines]
> >> >>
> >> >> Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.