ItemStyle-VerticalAlign="Middle" not work in asp:GridView
Why ItemSty开发者_开发百科le-VerticalAlign="Middle" not work in asp:GridView?, this is my code
<asp:GridView ID="GridView1" runat="server" RowStyle-VerticalAlign="Middle" >
<Columns>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText='<%$ Resources:Language, Admin_Employee_TimeTracker_GV_Code %>'>
<ItemTemplate>
<asp:TextBox id="txtReferenceCode" runat="server" text='<%# Bind("referenceCode")%>' MaxLength="100" Width="100px"></asp:TextBox>
</ItemTemplate>
<ItemStyle VerticalAlign="Middle" />
</asp:TemplateField>
Run the page, right-click, and view source; it's probably adding the style to the wrong element. I think it adds it to the row, which it's not setting correctly? I've experienced something like that with the empty data template...
Take a look and see which underlying HTML element it applies it too first.
You should use like this;
<asp:GridView ID="GridView1" runat="server" RowStyle-VerticalAlign="Middle" CssClass="GridView1" >
<Columns>
<asp:TemplateField ItemStyle-VerticalAlign="Middle" HeaderText='<%$ Resources:Language, Admin_Employee_TimeTracker_GV_Code %>'>
<ItemTemplate>
<asp:TextBox id="txtReferenceCode" runat="server" text='<%# Bind("referenceCode")%>' MaxLength="100" Width="100px"></asp:TextBox>
</ItemTemplate>
<ItemStyle VerticalAlign="Middle" />
</asp:TemplateField>
And Css part will be like this;
<style type="text/css">
.GridView1 tbody tr th {
vertical-align: central !important;
text-align: center !important;
}
</style>
精彩评论