我试过的CSS是:
.RowStyle {
height: 50px;
}
.AlternateRowStyle {
height: 50px;
}
我目前使用的HTML是:
<asp:Panel runat="Server" ID="AnonymousMessagePanel">
<br />
<asp:GridView ID="CompletedProjectsGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="ProjectsClosedList"
EnableViewState="False" DataKeyNames="ProjectID" CssClass="mGrid" PagerStyle-CssClass="pgr" RowStyle-CssClass="RowStyle"
AlternatingRowStyle-CssClass="alt" AllowPaging="true" PageSize="10">
<Columns>
<asp:BoundField DataField="ProjectID" HeaderText="ProjectID" HeaderStyle-ForeColor="White" SortExpression="ProjectID" ReadOnly="True" ItemStyle-Width="11%"/>
<asp:BoundField DataField="ProjectName" HeaderText="ProjectName" HeaderStyle-ForeColor="White" SortExpression="ProjectName" ItemStyle-Width="11%"/>
<asp:BoundField DataField="TesterName" HeaderText="TesterName" HeaderStyle-ForeColor="White" SortExpression="TesterName" ItemStyle-Width="11%"/>
<asp:BoundField DataField="ProjectDescription" HeaderText="ProjectDescription" HeaderStyle-ForeColor="White" SortExpression="ProjectDescription" ItemStyle-Width="11%"/>
<asp:BoundField DataField="Platform" HeaderText="Platform" HeaderStyle-ForeColor="White" SortExpression="Platform" ItemStyle-Width="11%"/>
<asp:BoundField DataField="DueDate" HeaderText="DueDate" HeaderStyle-ForeColor="White" SortExpression="DueDate" dataformatstring="{0:M/dd/yyyy}" ItemStyle-Width="11%"/>
<asp:BoundField DataField="DateAssigned" HeaderText="DateAssigned" HeaderStyle-ForeColor="White" SortExpression="DateAssigned" dataformatstring="{0:M/dd/yyyy}" ItemStyle-Width="11%"/>
<asp:BoundField DataField="DocumentName" HeaderText="DocumentName" HeaderStyle-ForeColor="White" SortExpression="DocumentName" ItemStyle-Width="11%"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="ProjectsClosedList" runat="server"
ConnectionString="<%$ ConnectionStrings:ProjectsAndTasksTestConnectionString %>"
SelectCommand="SELECT [ProjectID], [ProjectName], [TesterName], [ProjectDescription], [Platform], [DueDate], [DateAssigned], [DocumentName] FROM [Projects] WHERE ([DateCompleted] IS NULL)">
</asp:SqlDataSource>
</asp:Panel>
注意:所有这些方法都可以实际运行和工作,当最后一页上只有2/10时,它们都会改变gridview的高度,无论页面中的内容是什么,我都需要相同的高度< / p>
如果这不是实现这一目标的最佳方式,我愿意接受更好的选择
答案 0 :(得分:0)
.RowStyle,.AlternateRowStyle{
box-sizing: border-box
}
或只是
* { box-sizing: border-box }
您也可以查看max-height
答案 1 :(得分:0)
尝试删除RowStyle-CssClass="RowStyle
并执行此操作,看看它是否有效:
<asp:BoundField DataField="ProjectID" HeaderText="ProjectID" HeaderStyle-ForeColor="White" SortExpression="ProjectID" ReadOnly="True">
<ItemStyle CssClass="RowStyle"></ItemStyle>
</asp:BoundField>
不知怎的,我觉得你的其他一些风格正在影响身高。
或尝试以下操作:
.RowStyle
{
height: 50px !important;
}
.AlternateRowStyle
{
height: 50px !important;
}