日期:2014-05-20  浏览次数:20541 次

如何在gridview的加入滚动条?
如何在gridview的加入滚动条?如果超高,就出现上下滚动条,如果超宽,出现左右滚动条

哪位给一个段代码?

------解决方案--------------------

------解决方案--------------------
asp:Panel ID="Panel1" runat="server" Height="185px" ScrollBars="Auto" Width="641px">
<asp:GridView ID="DG" runat="server" AllowPaging="True" AutoGenerateColumns="False" Width="865px" ForeColor="#000040">
</asp:GridView>
</asp:Panel>


.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
 
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}

<div style="overflow-y: scroll; height: 200px;width:300px" id="dvBody">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="3" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" Font-Size="12px" OnRowCreated="GridView1_RowCreated" >
<FooterStyle BackColor="White" ForeColor="#000066" />
<Columns>
<asp:BoundField DataField="姓名" HeaderText="姓名" />

</Columns>
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" CssClass="ms-formlabel DataGridFixedHeader"/>
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" CssClass="Freezing"/>
</asp:GridView>
</div>

gridview72例
------解决方案--------------------
外面加个div就行,让div出现滚动条