我的页面上有几个 girdviws,我希望每个都采用我为它定义的大小。我将gridview宽度设置如下
<asp:GridView ID="GridView1" runat="server" width="1020px">
</asp:GridView>
它忽略宽度并超出背景边框。我从 SO 中的类似问题中学到了如下定义每个列的宽度。
以上也失败了。这真的令人沮丧>请任何替代方案将不胜感激。
使用Panel控件通过水平和垂直滚动选项为 GridView 提供宽度。
<asp:Panel ID="Panel1" runat="server" ScrollBars="Both"
Height="1020" Width="1020">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</asp:Panel>
或者我们也可以<div>
使用溢出属性来做类似的事情:
<div style="width:100%; height:300; overflow:auto;">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
尝试这个:
<asp:GridView ID="GridView1" runat="server" style="width: 1020px !important; max-width: 1020px !important;">
</asp:GridView>