Elvis'‖.Net‖Space
                                 ┏=想获得小成功,必须掌握足够的技巧.
                                    =想获得大成功,必须掌握扎实的基础.
                                    =想获得更高成就,实现更高理想,在前两者基础上,加上善于思考. ┓
随笔- 81  文章- 514  评论- 0 
  首页    联系  管理  订阅 订阅

DataGrid表头不动,表身动

用Div形式实现,实现功能显示表格
<%@ Page language="c#" Codebehind="dg1.aspx.cs" AutoEventWireup="false" Inherits="netLearn.dg1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>dg1</title>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="C#" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  <script language="javascript">
  function window.onload()
  {
   var dg = document.getElementById('DataGrid1');
   var strHTML = "";
   for( var i=1; i<dg.rows.length;i++)
   {
    strHTML += dg.rows[i].cells[0].innerHTML;
   }   
   dg.rows[1].cells[0].innerHTML = "<div id='dgContent' style='height:250px;overflow-y:scroll'>" + strHTML + "</div>";
   for( var i=dg.rows.length-1; i>1;i--)
   {
    dg.deleteRow(i);
   } 
  }
  </script>

 </HEAD>
 <body MS_POSITIONING="FlowLayout">
  <form id="Form1" method="post" runat="server">
   <FONT face="宋体">
    <asp:datagrid id="DataGrid1" runat="server" Width="576px" Height="192px" AutoGenerateColumns="False"
     BorderWidth="0px" CellPadding="0">
     <Columns>
      <asp:TemplateColumn>
       <HeaderTemplate>
        <table cellpadding="2" cellspacing="1" bgcolor="PaleTurquoise" width="100%">
         <tr>
          <th bgcolor="#006699" width="25%" align="center" style="color:#ffffff">
           序号</td>
           <th bgcolor="#006699" width="25%" align="center" style="color:#ffffff">
            ID号</td>
            <th bgcolor="#006699" width="25%" align="center" style="color:#ffffff">
             姓名</td>
             <th bgcolor="#006699" width="25%" align="center" style="color:#ffffff">
          年龄</td>
         </tr>
        </table>
       </HeaderTemplate>
       <ItemTemplate>
        <table cellpadding="2" cellspacing="1" bgcolor="PaleTurquoise" width="100%">
         <tr>
          <td bgcolor="LightSkyBlue" width="25%" style="padding-left:10px;"><%#Container.ItemIndex+1%></td>
          <td bgcolor="LightSkyBlue" width="25%" style="padding-left:10px;"><%#DataBinder.Eval(Container.DataItem,"ID")%></td>
          <td bgcolor="LightSkyBlue" width="25%" style="padding-left:10px;"><%#DataBinder.Eval(Container.DataItem,"Name")%></td>
          <td bgcolor="LightSkyBlue" width="23%" style="padding-left:10px;"><%#DataBinder.Eval(Container.DataItem,"Age")%></td>
         </tr>
        </table>
       </ItemTemplate>
      </asp:TemplateColumn>
     </Columns>
    </asp:datagrid></FONT></form>


 </body>
</HTML>

效果如下:
 
posted @ 2006-10-18 14:23 '.Elvis.' 阅读(7) 评论(0)  编辑 收藏 网摘 所属分类: DotNet&C#
Copyright ©2008 '.Elvis.'
<2008年12月>
日一二三四五六
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

与我联系

  • 发短消息

搜索

 

文章分类(506)

  • Ajax(16)
  • Asp(14)
  • C# Base(8)
  • Computer Skill(10)
  • Controls&Componets(3)
  • DevelopNote(7)
  • DotNet&C#(214)
  • IBatis+Sprint.Net(7)
  • Java&Jsp(9)
  • Javascript(53)
  • JQuery(4)
  • OOP(10)
  • Refactoring(4)
  • Report(27)
  • SkillTabloid(14)
  • SoftDoc(2)
  • SoftTest(4)
  • SQL(49)
  • Virus(3)
  • Web 2.0(1)
  • WebDesign(29)
  • WebService(6)
  • XML(12)

文章档案(514)

  • 2008年11月 (1)
  • 2008年9月 (1)
  • 2008年8月 (2)
  • 2008年6月 (3)
  • 2008年5月 (6)
  • 2008年4月 (2)
  • 2008年3月 (2)
  • 2008年2月 (3)
  • 2008年1月 (15)
  • 2007年12月 (8)
  • 2007年11月 (8)
  • 2007年10月 (6)
  • 2007年8月 (3)
  • 2007年7月 (1)
  • 2007年6月 (11)
  • 2007年5月 (3)
  • 2007年4月 (10)
  • 2007年3月 (31)
  • 2007年2月 (35)
  • 2007年1月 (62)
  • 2006年12月 (101)
  • 2006年11月 (82)
  • 2006年10月 (94)
  • 2006年9月 (24)

NetWebs

  • 21aspnet
  • Asp.net Forums
  • C# Books
  • Cfyc
  • ChinaCs
  • codesearch
  • CustomComponets
  • dotnettools
  • HuiDuControl
  • krugle
  • Microsoft Help
  • mikecat
  • MSDN
  • singlepine
  • torome
  • Yesky Vs2005