将Gridview高度设置为ASP.Net的百分比

时间:2016-05-19 13:35:02

标签: c# html css asp.net gridview

我在页面上有一个gridview控件。我的页面所有高度都是百分比。由于所有div都工作正常。只有gridview不接受百分比,因为我在gridview控件上放置了固定标题以显示其标题。

如果我给它的类提供pixles,它会接受并将滚动条放在一边。但是如果我给出10%或20%gridview填充所有记录的百分比并扩展到最后。

我的代码如下:

css Class **

.containergrid {
    height: 10%;
    overflow: auto;
    background-color: forestgreen;
}

gridview control **

<div class="containergrid">
    <asp:GridView ID="grdCost" runat="server" AutoGenerateColumns="False"
        CssClass="table table-hover table-striped" ShowHeader="false"
        DataKeyNames="CostID"
        OnRowCommand="grdCost_RowCommand" OnRowDataBound="grdCost_RowDataBound"
        BorderStyle="None" BorderWidth="0px" CellPadding="1" GridLines="None" Font-Size="Small">
        <Columns>
            <asp:BoundField DataField="CostName">
                <ItemStyle CssClass="col-md-9 col-sm-9 col-xs-9"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="Percentage" DataFormatString="{0:0}%">
                <ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1"></ItemStyle>
            </asp:BoundField>
            <asp:BoundField DataField="Active">
                <ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1"></ItemStyle>
            </asp:BoundField>
            <asp:TemplateField HeaderText="Option">
                <ItemTemplate>
                    <asp:LinkButton ID="btnEdit" CommandName="editRecord"
                        CommandArgument='<%# Eval("CostID") + "," + Eval("CostName") + "," + Eval("Percentage") + "," + Eval("Active")%>' runat="server">
                    <span class="glyphicon glyphicon-pencil" style="padding-left:30px"></span>
                    </asp:LinkButton>

                    <asp:LinkButton ID="btnDelete" CommandName="deleteRecord"
                        CommandArgument='<%# Eval("CostID") + "," + Eval("CostName")%>' runat="server">
                        <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                    </asp:LinkButton>
                </ItemTemplate>
                <ItemStyle CssClass="col-md-1 col-sm-1 col-xs-1 col-md-pull-1"></ItemStyle>
            </asp:TemplateField>
        </Columns>

        <RowStyle BackColor="White" ForeColor="#333333" />
    </asp:GridView>
</div>

请帮忙。感谢

0 个答案:

没有答案