a) As far as I know, GridView’s RowStyle-HorizontalAlign
property should overwrite CSS’s text-align
property, and thus text inside GridView's cells should be located on the left side of the cells, but is instead moved to the right side. Why is that?
b) Similarly, RowStyle-Font-Bold
should overwrite CSS’s font-weight
property and thus fonts shouldn’t be in bold. But again, CSS’s property overwrites RowStyle’s Font-Bold
property. Why?
<div id="someClass">
<asp:GridView ID="gvwShowUsers" runat="server" >
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" Font-Bold="false"
HorizontalAlign="Left" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" />
</Columns>
</asp:GridView>
</div>
CSS file:
#someClass td
{
font-weight:bolder;
text-align:right;
}
thanx
EDIT:
A workaround would be to apply the style to each field instead (e.g. ItemStyle-HorizontalAlign)
I tried with applying ItemStyle
to GridView’s
field:
<div id="someClass">
<asp:GridView ID="gvwShowUsers" runat="server" >
<RowStyle Font-Bold="false" HorizontalAlign="Left" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName">
<ItemStyle HorizontalAlign="Left" Font-Bold="false" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
But since even after applying ItemStyle
the page still displayed text on the right side of the cells, I've decided to check the source code of a html page sent to the user, and as it turns out both <tr>
and <td>
elements have Align
property set to left
, so...totally confused!
Here is the source code of a html page:
<table id="GridView1" style="font-weight:normal;">
<tr align="center" style=" font-weight:bold;">
<th scope="col">UserName</th>
</tr>
<tr align="right" valign="bottom" style="font-weight:normal;">
<td align="right" style="font-weight:normal;"> Nancy</td>
</tr>
</table>