Saturday, April 21, 2012

Left or Right alignment in Gridview Columns

When we work with Grid-view we need to make left or right or centered alignment on column values according to their Datatype.For example we have to make right aligned all money values and character values to be left aligned. To do this just embed column within table like given example -:

 <asp:TemplateField HeaderText="Debit">
          <ItemTemplate>
                    <table align="right"  ><tr><td>
                                <asp:Label ID="lblDebit" runat="server" Text='<%# Bind("Debit") %>'></asp:Label>
                    </td></tr></table>
          </ItemTemplate>
 </asp:TemplateField>

Hope you'll get it. Enjoy coding.

No comments:

Post a Comment