0

当我的gridview 的数据变大时,即当页面大小增加到10 时,gridview 会超出主页面区域。图片清楚地描述了我的话。有人可以帮我解决这个问题吗?谢谢。在此处输入图像描述

    my CSS:

        body
        {
            margin-top: 0px;
            background-image: url('../Images/bg_gradient.png');
            background-repeat: repeat-x;
            background-color: #c6dee8;
        }

        #wrapper
        {
            border: 0px solid green;
            width: 980px;
            margin-right: auto;
            margin-left: auto;
        }


            #main
        {
            width: 978px;
            min-height: 750px;
            max-height: 1000px;
            overflow: auto;
            border: 1px solid black;
        }

        #leftContent
        {
            width: 180px;
            min-height: 750px;
            max-height: 1000px;
            float: left;
            border-right: 1px solid black;
        }
#recordDisplaydiv
{
    padding-top: 50px;
}

My Markup Code:

        <div id="recordDisplaydiv">
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <asp:GridView ID="gvContract" runat="server" AutoGenerateColumns="False" DataKeyNames="ContractID"
                            CssClass="mGrid" OnPageIndexChanging="gvContract_PageIndexChanging" OnRowCommand="gvContract_RowCommand"
                            EmptyDataText="No Record Exist" PageSize="10" AllowPaging="true">
                            <AlternatingRowStyle CssClass="alt" />
                            <Columns>
                                <asp:BoundField DataField="KeyWinCountNumber" HeaderText="KeyWin Count#" />
                                <asp:BoundField DataField="ItemName" HeaderText="Item" />
                                <asp:BoundField DataField="BrandName" HeaderText="Brand" />
                                <asp:BoundField DataField="CountName" HeaderText="Count" />
                                <asp:BoundField DataField="SellerName" HeaderText="Seller" />
                                <asp:BoundField DataField="BuyerName" HeaderText="Buyer" />
                                <asp:BoundField DataField="ContractNumber" HeaderText="Contract#" />
                                <asp:BoundField DataField="ContractDate" HeaderText="Contract Date" />
                                <asp:BoundField DataField="CountryFromName" HeaderText="Country From" />
                                <asp:BoundField DataField="CountryToName" HeaderText="Country To" />
                                <asp:BoundField DataField="UnitName" HeaderText="Unit Name" />
                                <asp:BoundField DataField="TQty" HeaderText="Total Qty" />
                                <asp:BoundField DataField="Vans" HeaderText="Vans" />
                                <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" />
                                <asp:BoundField DataField="TAmount" HeaderText="Total Amount" />
                                <asp:TemplateField HeaderText="Delete">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="imgDelete" runat="server" ImageUrl='<%# isDelete_img(Session["isAdmin"].ToString()) %>'
                                            CommandName="DeleteRecord" Enabled='<%# isDelete(Session["isAdmin"].ToString()) %>'
                                            CommandArgument='<%# Eval("ContractID") %>' AlternateText="DeleteRecord" OnClientClick="return confirm_delete();"
                                            Style='<%# delete_style(Session["isAdmin"].ToString()) %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Edit">
                                    <ItemTemplate>
                                        <asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Images/edit.png" CommandName="EditRecord"
                                            CommandArgument='<%# Eval("ContractID") %>' AlternateText="EditRecord" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <PagerStyle CssClass="pgr" />
                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
                <div id="ContractbtnExportdiv">
                    <asp:Button ID="btnExport" runat="server" CssClass="btnExportdiv" OnClick="btnExport_Click" />
                </div>
            </div>
4

4 回答 4

1

将gridview放在可滚动的div中,这将解决问题

<div style="width:300px;height:250px;overflow:auto;">
  <gridview>
</div>
于 2012-11-02T10:53:49.823 回答
0

使用overflow-y:auto;属性来解决问题。

div.classname {
  overflow-y:auto;
} 
于 2012-11-02T11:01:17.420 回答
0

尝试删除:

max-height: 1000px;

从你的#main 和#leftContent div

于 2012-11-02T11:07:50.433 回答
-1

使用 overflow-y 作为 auto 并maximum-height为两个面板删除,即 for#main#leftContent并将高度作为 100% 作为 auto 应用到#leftContent. 这可能会有所帮助。

于 2012-11-02T11:13:57.397 回答