前台
<script>
function scrool()
{
var t = document.getElementById("<%=gvCheckList.ClientID%>");
var t2 = t.cloneNode(true)
for(i = t2.rows.length -1;i > 0;i--)
t2.deleteRow(i)
t.deleteRow(0)
head1.appendChild(t2)
}
window.onload = scrool
</script>
<div id="head1"></div>
<div style="height:186px;width:100%;overflow-y: scroll;">
<asp:GridView ID="GridView1" runat="server" Width="97%" >
<RowStyle Height="26px" />
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
后台代码
Page_Load
this.GridView1.Attributes.Add("style", "table-layout:fixed");
---------------------------------------------------------------------------------------------------------------------
string constr = @"data source=.\mssqlserver1;database=northwind;uid=sa;pwd=123456";
northwindDataContext ctx = new northwindDataContext(constr);
var order = from o in ctx.Orders
where o.EmployeeID==4 && o.ShipCountry=="USA"
select o;
var order2 = order.Take(10);
GridView1.DataSource = order2;
GridView1.DataBind();