Does anybody knows how to right-align a header of just one column of a gridview. Been searching the web and still cannot find a solution for it.
The HorizontalAlign='Right' works for the data, but not for the header. I do not want to right-align all columns but just one.
Here's an excerpt of the code:
<asp:GridView ID="gvCustomer" AutoGenerateColumns="False" runat="server">
<Columns>
<asp:BoundField DataField="CustomerId" HeaderText="Customer Id" />
(other fields here)
<asp:TemplateField HeaderText="Contact Name" HeaderStyle-HorizontalAlign="Right" >
<ItemTemplate>
<asp:Label runat="server" ID="lblContactName" Text='<%# Eval("ContactName") %>' />
</ItemTemplate>
<ItemStyle HorizontalAlign="Right" />
<HeaderStyle HorizontalAlign="Right" />
</asp:TemplateField>
</Columns>
</asp:GridView>
Any help is appreciated. Thanks!
Niki
1 You can define on your control GridView
<HeaderStyle HorizontalAlign="Right" />
Note: delete your tag from item. he must be on your GridView control
So
<asp:GridView ID="gvCustomer" AutoGenerateColumns="False" runat="server">
<HeaderStyle HorizontalAlign="Right" />
.....
</asp:GridView>
2 Or you can define on your Item
<asp:TemplateField HeaderStyle-HorizontalAlign="Right">
Note: with this solution delete <HeaderStyle HorizontalAlign="Right" />
(must be inside your GridView not item)