Click here to Skip to main content
15,923,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to align girdview cells in gridview . i am using item template of gridview . and using lable control in it. what property of gridview controls helps us to align the cells.
Posted

Use RowStyle[^] property
XML
<asp:GridView ID="Gridview1" runat="server">
<RowStyle HorizontalAlign="Right" />
</asp:GridView>

If you want to align particular column try this
ASP.NET
<asp:boundfield headertext="Column1" datafield="Column1" headerstyle-horizontalalign="Right" footerstyle-horizontalalign="Right" itemstyle-horizontalalign="Right" xmlns:asp="#unknown" />

In your question you are using ItemTemplate so use CSS
ASP.NET
<asp:label id="Label1" runat="server" text="Label1" style="text-align:right;" xmlns:asp="#unknown"></asp:label>
 
Share this answer
 
Comments
Espen Harlinn 9-Feb-12 9:59am    
5'ed!
Hi,
Soluion that thatraja provided is ok. He is one more way how to align itemtemplate cell in grid.
HTML
...
    <headerstyle horizontalalign="Center" />
    <itemstyle horizontalalign="Center" />

His "RowStyle" example will align all clls in row.
Off course, you can use standard CSS properties to adjust styles of any asp.net control (element).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900