gpt4 book ai didi

c# - 绑定(bind)到 SqlDataAdapter 后,ASP.NET GridView 宽度不会保持在 100%

转载 作者:行者123 更新时间:2023-11-28 01:42:29 24 4
gpt4 key购买 nike

我有一个 GridView 并希望它的宽度保持在 100%。它在设计 View 中看起来不错,所以我假设一些关于与 SqlDataAdapter 绑定(bind)的东西会重置宽度以适应数据,但我希望它保持在 100%。宽度最终是支持绑定(bind)数据所需的任何宽度。

诚然,我对所有这一切都是陌生的,所以我相信你们所有人都会比我更清楚答案。

<div id="X" class="In-lineControl" style="width:100%">
<asp:GridView ID="XGV" runat="server" CssClass="GridView" BorderStyle="Groove">
<AlternatingRowStyle BackColor="#B4C2E0" />
<HeaderStyle BackColor="#6C88C4" ForeColor="White" />
</asp:GridView>
</div>

XData.SelectCommand = cmd;
DataTable XDT = new DataTable();
XData.Fill(XDT);
XGV.DataSource = XDT;
XGV.DataBind();

.GridView{
width:100%;
}

.In-lineControl{
display:block;
margin-top: 5px;
margin-bottom: 10px;
}

The GridView should extend its width out to 100% of the white area. It does in the design view, but the width changes after binding a SqlDataAdapter in the code behind.

最佳答案

您应该检查 CssClass GridView 并查看那里是否设置了宽度。

关于c# - 绑定(bind)到 SqlDataAdapter 后,ASP.NET GridView 宽度不会保持在 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25065926/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com