gpt4 book ai didi

c# - GridView 列大小不更改 ASP.NET

转载 作者:太空宇宙 更新时间:2023-11-04 11:41:10 25 4
gpt4 key购买 nike

我正在尝试增加 gridview 中其中一列的大小,但是,无论我如何尝试增加大小,列宽都无法增加。 GridView 的数据正在我的 c# 代码中检索,该代码从我的数据库中获取数据。我检查了我的 gridview 类的 Css 代码,似乎没有什么影响列的宽度(或者至少我认为)。为什么我的列宽不会改变?

这是我目前的设置:ASP.NET:

 <div id="grid" style="overflow-x: auto; margin: auto; min-width: 100%; min-height: 100px; text-align: center;">
<asp:Label runat="server" ID="empty" Font-Size="15px" Font-Bold="True" Visible="false"></asp:Label>
<asp:GridView runat="server" ID="lessonsgrid" CssClass="gridview" AutoGenerateColumns="false">
<Columns>
<asp:BoundField ItemStyle-Width="1%" HeaderText="Id" SortExpression="Id" DataField="Id" />
<asp:BoundField ItemStyle-Width="10%" HeaderText="Release" SortExpression="Release" DataField="Release" />
<asp:BoundField ItemStyle-Width="10%" HeaderText="Category" SortExpression="Category" DataField="Category" />
<asp:BoundField ItemStyle-Width="10%" HeaderText="Subcategory" SortExpression="Subcategory" DataField="Subcategory" />
<asp:BoundField ItemStyle-Width="20%" ItemStyle-CssClass="descriptionCol" ItemStyle-HorizontalAlign="Left" HeaderText="Description" SortExpression="Description" DataField="Description" />
<asp:BoundField ItemStyle-Width="10%" HeaderText="Identifying Team" SortExpression="Identifying Team" DataField="Identifying Team" />
<asp:BoundField ItemStyle-Width="5%" HeaderText="Name" SortExpression="Name" DataField="Name" />
<asp:BoundField ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left" HeaderText="Suggestions For Improvement" SortExpression="Suggestions For Improvement" DataField="Suggestions For Improvement" />
<asp:BoundField ItemStyle-Width="5%" HeaderText="Team Assigned To" SortExpression="Team Assigned To" DataField="Team Assigned To" />
<asp:BoundField ItemStyle-Width="5%" HeaderText="Implemented" SortExpression="Implemented" DataField="Implemented" />
<asp:BoundField ItemStyle-Width="5%" HeaderText="Priority" SortExpression="Priority" DataField="Priority" />
<asp:BoundField ItemStyle-Width="5%" HeaderText="Implement Complexity" SortExpression="Implement Complexity" DataField="Implement Complexity" />
<asp:BoundField ItemStyle-Width="10%" HeaderText="Target Implement Date" SortExpression="Target Implement Date" DataField="Target Implement Date" />
<asp:BoundField ItemStyle-Width="10%" ItemStyle-HorizontalAlign="Left" HeaderText="Comment" SortExpression="Comment" DataField="Comment" />
</Columns>
</asp:GridView>
</div>

CSS .gridview:

.gridview a:link {
color: #0043bd;
font-weight: bold;
text-decoration: none;
}

.gridview a:visited {
color: #0043bd;
font-weight: bold;
text-decoration: none;
}

.gridview a:active,
.gridview a:hover {
color: #bd5a35;
text-decoration: underline;
}

.gridview {
font-family: Arial, Helvetica, sans-serif;
color: #666;
font-size: 12px;
text-shadow: 1px 1px 0px #fff;
background: #eaebec;
margin: 20px;
border: #ccc 1px solid;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 1px 2px #d1d1d1;
-webkit-box-shadow: 0 1px 2px #d1d1d1;
box-shadow: 0 1px 2px #d1d1d1;
}

.gridview th {
padding: 10px 25px 10px 25px;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
background: #ededed;
background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#ebebeb));
background: -moz-linear-gradient(top, #ededed, #ebebeb);
}

.gridview th:first-child {
text-align: left;
padding-left: 20px;
}

.gridview tr:first-child th:first-child {
-moz-border-radius-topleft: 3px;
-webkit-border-top-left-radius: 3px;
border-top-left-radius: 3px;
}

.gridview tr:first-child th:last-child {
-moz-border-radius-topright: 3px;
-webkit-border-top-right-radius: 3px;
border-top-right-radius: 3px;
}

.gridview tr {
text-align: center;
padding-left: 20px;
}

.gridview td:first-child {
text-align: left;
padding-left: 20px;
border-left: 0;
}

.gridview td {
padding: 10px;
border-top: 1px solid #ffffff;
border-bottom: 1px solid #e0e0e0;
border-left: 1px solid #e0e0e0;
background: #fafafa;
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));
background: -moz-linear-gradient(top, #fbfbfb, #fafafa);
}

.gridview tr.even td {
background: #f6f6f6;
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#f6f6f6));
background: -moz-linear-gradient(top, #f8f8f8, #f6f6f6);
}

.gridview tr:last-child td {
border-bottom: 0;
}

.gridview tr:last-child td:first-child {
-moz-border-radius-bottomleft: 3px;
-webkit-border-bottom-left-radius: 3px;
border-bottom-left-radius: 3px;
}

.gridview tr:last-child td:last-child {
-moz-border-radius-bottomright: 3px;
-webkit-border-bottom-right-radius: 3px;
border-bottom-right-radius: 3px;
}

.gridview tr:hover td {
background: #f2f2f2;
background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0));
background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0);
}

最佳答案

很遗憾,我还不能添加评论,但您在所有元素上都使用了百分比。需要有一个具有实际固定宽度的元素。这样,百分比就知道要占用该宽度的百分比。

关于c# - GridView 列大小不更改 ASP.NET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31322305/

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