两个DIV各包含了一个GRIDVIEW,刚打开页面时是有滚动条的,为什么点了切换后滚动条就没了?
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
if (i == Num)
{
   thisObj.className = "active"; 
      document.getElementById(tabObj+"_Content"+i).style.display = "inline";
}else{
   tabList[i].className = "normal"; 
   document.getElementById(tabObj+"_Content"+i).style.display = "none";
}

}
div class="TabTitle">
              <ul id="myTab0">
                <li class="active" onclick="nTabs(this,0);">招标代理</li>
                <li class="normal" onclick="nTabs(this,1);">造价咨询</li>
               
              </ul>
            </div>
    <!-- 内容开始 -->
    <div class="TabContent">
      <div id="myTab0_Content0" style="overflow:auto; height:300px">
      <asp:GridView ID="GridView2" runat="server" BackColor="White" BorderColor="#3366CC"
                            BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowDataBound="GridView2_RowDataBound" style="float: left" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1">
                            <RowStyle BackColor="White" ForeColor="#003399" />
                            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                            <Columns>
                                <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True"
                                    SortExpression="id">
                                    <FooterStyle CssClass="gridview1" />
                                    <HeaderStyle CssClass="gridview1" />
                                    <ItemStyle CssClass="gridview1" />
                                </asp:BoundField>
                                <asp:BoundField DataField="bianhao" HeaderText="编号" SortExpression="bianhao" />
                                <asp:BoundField DataField="xmname" HeaderText="项目名称" SortExpression="xmname" />
                                <asp:BoundField DataField="kfname" HeaderText="客户名称" SortExpression="kfname" />
                                <asp:BoundField DataField="Column1" HeaderText="开始时间" ReadOnly="True" SortExpression="Column1" />
                                <asp:BoundField DataField="xmlc" HeaderText="项目流程" SortExpression="xmlc" >                               
                                    <FooterStyle CssClass="gridview1" />
                                    <HeaderStyle CssClass="gridview1" />
                                    <ItemStyle CssClass="gridview1" />
                                </asp:BoundField>
                                 <asp:BoundField DataField="a13" HeaderText="报名结束时间" SortExpression="a13" />
                                <asp:BoundField DataField="a24" HeaderText="开标时间" SortExpression="a24" />
                                 
                            </Columns>
                        </asp:GridView></div>
      <div id="myTab0_Content1" class="gridview1" style="overflow:auto; height:300px" >
      <asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False"
                            DataSourceID="SqlDataSource2" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" OnRowDataBound="GridView3_RowDataBound">
                            <Columns>
                                <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" >
                                    <FooterStyle CssClass="gridview1" />
                                    <HeaderStyle CssClass="gridview1" />
                                    <ItemStyle CssClass="gridview1" />
                                </asp:BoundField>
                                <asp:BoundField DataField="bianhao" HeaderText="项目编号" ReadOnly="True" SortExpression="bianhao" />
                                <asp:BoundField DataField="xmname" HeaderText="项目名称" ReadOnly="True" SortExpression="xmname" />
                                <asp:BoundField DataField="kfname" HeaderText="客户名称" ReadOnly="True" SortExpression="kfname" />
                                <asp:BoundField DataField="Column1" HeaderText="开始时间" ReadOnly="True" SortExpression="Column1" />
                            </Columns>
                            <RowStyle BackColor="White" ForeColor="#003399" />
                            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                            <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                            <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                        </asp:GridView></div>    
    </div>
</div>

解决方案 »

  1.   

    第一个GridView里面的数据量过大 所以会产生滚动条出来  而第二个GridView数据量肯定没多少 所以没有滚动条  你可以把第二个div的高度设置小一点 你就明白了~~
      

  2.   

    楼上说根据数据量自适应是一种情况。如果第二个数据量也很多,但没出现应该出现的滚动条,就看看第二个DIV的CSS是否有区别,如果使用了OVERFLOW:HIDDEN,就不会出现滚动条了。
      

  3.   

    .nTab{
    float: left;
    width: 100%;
    margin: 0 auto;
    border-bottom:1px #AACCEE solid;
    background:#d5d5d5;
    background-position:left;
    background-repeat:repeat-y;
    margin-bottom:2px;
    }
    .nTab .TabTitle{
    clear: both;
    height: 22px;
    overflow: hidden;
    }
    .nTab .TabTitle ul{
    border:0;
    margin:0;
    padding:0;
    }
    .nTab .TabTitle li{
    float: left;
    width: 70px;
    cursor: pointer;
    padding-top: 4px;
    padding-right: 0px;
    padding-left: 0px;
    padding-bottom: 2px;
    list-style-type: none;
    font-size: 12px;
    text-align: center;
    margin: 0;
    }
    .nTab .TabTitle .active{background:#fff;border-left:1px #AACCEE solid;border-top:1px #AACCEE solid;border-right:1px #AACCEE solid;border-bottom:1px #fff solid; width:120px;}
    .nTab .TabTitle .normal{background:#EBF3FB;border:1px #AACCEE solid;width:120px;}
    .nTab .TabContent{
    width:auto;background:#fff;
    margin: 0px auto;
    padding:10px 0 0 0;
    border-right:1px #AACCEE solid;border-left:1px #AACCEE solid;
    }
    没用HIDDEN~~~