Asp.net GridView Headertext aligment problem with the Column text
In my GridView
the Headertext
is aligned to left and itemstyle
is aligned to left but the 开发者_JAVA百科header is not exactly aligned to left. It leaves some space before.
Saml code: <asp:BoundField DataField="COMPANY_TYPE" SortExpression="Company_Type" HeaderText="Company Type" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Width="10%"/>
It's possible that your padding on the <th>
elements in the header is larger than the <td>
elements in the item rows. Use Firebug (or equivalent) to check if something in your css is affecting it. I would also look into the source of the page to verify that there is not any extra whitespace or anything before your column headers.
In the column section where you set the fields add this
ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"
for example:
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"/>
Try
.HeaderStyle {
text-align: Left
}
<asp:GridView runat="server" ID="TestAlign" ShowFooter="True"
DataSourceID="testDataSource" Width="600"
HeaderStyle-CssClass="HeaderStyle">
<Columns>
<asp:BoundField DataField="left" HeaderText="-left-"
HeaderStyle-CssClass="HeaderStyle" />
</Columns>
</asp:GridView>
精彩评论