<div class="codetitle"> <span><a style="CURSOR: pointer" data="87618" class="copybut" id="copybut87618" onclick="doCopy('code87618')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code87618"> <br><%@ Page Language="C#" AutoEventWireup= "true" %> <br><br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional .dtd"> <br><br><script runat="server"> <br>// 데이터에서 계산 데이터를 얻을 수 있습니다<br>ICollection CreateDataSource( ) <br>{ <br>System .Data.DataTable dt = new System.Data.DataTable(); <br>System.Data.DataRow dr <br>dt.Columns.Add(new System.Data.DataColumn("학생 클래스", typeof( System.String))); <br>dt.Columns.Add(new System.Data.DataColumn("학생 이름", typeof(System.String))) <br>dt.Columns.Add(new System.Data .DataColumn ("중국어", typeof(System.Decimal))); <br>dt.Columns.Add(new System.Data.DataColumn("수학", typeof(System.Decimal))) <br>dt. 열.Add(new System.Data.DataColumn("English", typeof(System.Decimal))) <br>dt.Columns.Add(new System.Data.DataColumn("컴퓨터", typeof(System.Decimal) )) ; <br><br>for (int i = 0; i < 50; i ) <BR>{ <BR>System.Random rd = new System.Random(Environment.TickCount * i); >dr = dt.NewRow(); <BR>dr[0] = "클래스" i.ToString(); <BR>dr[1] = "테스트" i.ToString(); = 시스템 .Math.Round(rd.NextDouble() * 100, 2); <BR>dr[3] = System.Math.Round(rd.NextDouble() * 100, 2) <BR>dr[4] = System .Math.Round(rd.NextDouble() * 100, 2); <BR>dr[5] = System.Math.Round(rd.NextDouble() * 100, 2) <BR>dt.Rows. Add( dr); <BR>System.Data.DataView dv = new System.Data.DataView(dt); <BR>return dv; <BR><BR>protected void Page_Load( 객체 sender, EventArgs e ) <BR>{ <BR>if (!IsPostBack) <br>{ <br>GridView1.Attributes.Add("style", "table-layout:fixed") <BR>GridView1.DataSource = CreateDataSource( ); <BR>GridView1.DataBind(); <BR>} <BR>} <BR><BR></script> <br><br><script type="text/javascript"> <br>function s() { <br>var t = document.getElementById("<%=GridView1.ClientID%>") <br>var t2 = t.cloneNode(true) <br>for (i = t2 .rows.length - 1; i > 0; i--) <br>t2.deleteRow(i) <br>t.deleteRow(0) <br>a.appendChild(t2) <br>} <br> window.onload = s <br></script> <br><br><html xmlns="http://www.w3.org/1999/xhtml"> <br><title>고정 헤더와 스크롤 가능한 본문이 있는 GridView 만들기<br> <br> </title> <br><form id="Form1" runat="server "><table> <br><tr> <br><td> <br><div id="a"> <br></div> <br>< div style="overflow-y: 스크롤; 높이: 200px"> <br><asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFFF" <BR> GridLines="Both" CellPadding="4" Width="560"> <br><HeaderStyle BackColor="#EDEDED" Height="26px" /> <br></asp:GridView> </div> <br></tr> <br></form> <br></body> /html> <br><br> </form> </div>