Home All Groups Group Topic Archive Search About
Author
30 Nov 2006 4:33 PM
Chuck P
I have a gridview but the alignment doesn't seem to work.
I want to center a button in one column and text in another.
The alignment doesn't work for either column.
It does pick up the Font-Bold/Italic though.

<asp:TemplateField AccessibleHeaderText="Detail" HeaderText="Access Detail"
ShowHeader="False" SortExpression="CandidateID">
      <ItemTemplate  >
         X<asp:Button ID="btnDetail" runat="server" CausesValidation="false"
Text='<%# Eval("CandidateID") %>'   OnClick="btnDetail_Click" />Y
      </ItemTemplate>
      <ItemStyle HorizontalAlign="Center" Font-Bold="true"
Font-Italic="true" />
</asp:TemplateField>

<asp:BoundField DataField="ExitDescription" HeaderText="ExitDescription"
SortExpression="ExitDescription" ItemStyle-HorizontalAlign="Right" />

Author
1 Dec 2006 1:59 AM
Walter Wang [MSFT]
Hi Chuck,

I just tried your code, it seems working correctly on my side. I've
attached the screenshot for your reference. It might be related other code
in your project. You may send me a complate reproducible project for
inspecting. Thanks.


Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
1 Dec 2006 9:57 AM
marss
Chuck P wrote:
Show quoteHide quote
> I have a gridview but the alignment doesn't seem to work.
> I want to center a button in one column and text in another.
> The alignment doesn't work for either column.
> It does pick up the Font-Bold/Italic though.
>
> <asp:TemplateField AccessibleHeaderText="Detail" HeaderText="Access Detail"
> ShowHeader="False" SortExpression="CandidateID">
>       <ItemTemplate  >
>          X<asp:Button ID="btnDetail" runat="server" CausesValidation="false"
> Text='<%# Eval("CandidateID") %>'   OnClick="btnDetail_Click" />Y
>       </ItemTemplate>
>       <ItemStyle HorizontalAlign="Center" Font-Bold="true"
> Font-Italic="true" />
> </asp:TemplateField>
>
>  <asp:BoundField DataField="ExitDescription" HeaderText="ExitDescription"
> SortExpression="ExitDescription" ItemStyle-HorizontalAlign="Right" />

Code is correct.
Maybe problem is caused by incorrect stylesheet. For example, if in
spite of your code both column items aligned to the left then look
through stylesheet for declaration:
    td
    {
       ....
       text-align:left;
       ....
    }
or if some CssClass applied to grid view
<... CssClass="gview" ...>
look for ".gview td", ".gview tr td", etc.