GridView列大小不更改ASP.NET

时间:2015-07-09 15:44:26

标签: c# html css asp.net gridview

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

这是我目前的设置: 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);
    }

1 个答案:

答案 0 :(得分:1)

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