rt

解决方案 »

  1.   

    如果你的talbe是动态写出来的,你可以参考下下面的方法
    using System.Text;
    protected string fixedHeader()
    {    
    StringBuilder s=new StringBuilder();
    s.Append(@"<table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'>");
    s.Append(@"<TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'>");
    s.Append(@"<TD nowrap>Header A</TD>");
    s.Append(@"<TD nowrap>Header B</TD>");
    s.Append(@"<TD nowrap>Header C</TD>");
    s.Append(@"</TR>");
    for(int m=0;m<100;m++)
    {
    if(m%5==0)
    {
    s.Append(@"<TR>");
    s.Append(@"<TD colspan=3>").Append("&nbsp;</TD>");
    s.Append(@"</TR>");
    }
    else
    {
    s.Append(@"<TR>");
    s.Append(@"<TD>A").Append(m).Append("</TD>");
    s.Append(@"<TD>B").Append(m).Append("</TD>");
    s.Append(@"<TD>C").Append(m).Append("</TD>");
    s.Append(@"</TR>");
    }

    }            
    s.Append(@"</table>");            
    return s.ToString();            
    }
      

  2.   

    protected string fixedHeader()
    {    
    StringBuilder s=new StringBuilder();
    s.Append(@"<table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'>");
    s.Append(@"<TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'>");
    s.Append(@"<TD nowrap>Header A</TD>");
    s.Append(@"<TD nowrap>Header B</TD>");
    s.Append(@"<TD nowrap>Header C</TD>");
    s.Append(@"</TR>");
    for(int m=1;m<100;m++)
    {
    if(m%5==0)
    {
    s.Append(@"<TR>");
    s.Append(@"<TD>A").Append(m).Append("</TD>");
    s.Append(@"<TD>B").Append(m).Append("</TD>");
    s.Append(@"<TD>C").Append(m).Append("</TD>");
    s.Append(@"</TR>");
    s.Append(@"<TR>");
    s.Append(@"<TD colspan=3>").Append("&nbsp;</TD>");
    s.Append(@"</TR>");
    }
    else
    {
    s.Append(@"<TR>");
    s.Append(@"<TD>A").Append(m).Append("</TD>");
    s.Append(@"<TD>B").Append(m).Append("</TD>");
    s.Append(@"<TD>C").Append(m).Append("</TD>");
    s.Append(@"</TR>");
    }

    }            
    s.Append(@"</table>");            
    return s.ToString();            
    }