本人试过好几种方法,最后还是使用另做表头的土法子,对位时有点上气接不了下气的感觉!

解决方案 »

  1.   

    自定义repeater?就是写个repeater的子类,在render里加固定的表头,添加滚动等
      

  2.   

    你表头不建到 repeater里面不行吗 
      

  3.   

    gridview 加 DIV 用js 实现就可以了,网上一般都是这么实现的
      

  4.   

    一般做法都是两个表格,一个用来显示表头,一个显示数据,显示数据的表格用DIV包起来,用CSS控制样式实现滚动。不过如果数据列值太长,会变形的我也希望能有一种更好的办法
      

  5.   

    在Repeater里面没有做过
    以前曾经组合html中的table,其实也就是两个table
      

  6.   

    对啊 表头为什么要建在repeater里面啊 建在外面 不可以吗
      

  7.   

    TO:color2002
    html里好做.TO:yagebu1983
       我现在用的就是div,但实现不了repeater的表头固定、表格滚动的效果
    能不能说说你的详细方法,不甚感谢
      

  8.   


    <asp:repeater... >
      <HeaderTemplate>
         表头(放出这个位会出错)
      </headertemplate>
         .
         .
    </asp:repeater>
      

  9.   

    <table >
    <tr>
    <th><th>
    </tr>
    <asp:repeater... > 
      <item..>
        <tr><td></td></tr>
      </item..>
    </asp:repeater>
      

  10.   


    .flowHeadStyle
    {
    position: relative;
    top: expression(this.offsetParent.scrollTop);
    }
    <body onload="formOnload();">
        <form id="form1" runat="server">
                        <div id="divMeasure" style="overflow: auto; width:100%; position: relative; left: 1px; top: 0px;">
                            <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
                                <HeaderTemplate>
                                    <table class="tableM" cellspacing="1" cellpadding="1">
                                        <tr class="flowHeadStyle" style="height:30px;">
                                            <td  style="width: 60px">接收日</td>
                                            <td class="tableM">管理No</td>
                                            <td class="tableM">产品型号</td>
                                            <td class="tableM">异常名称</td>
                                        </tr>
                                        <tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <td class="tableM" rowspan='<%# Eval("rows") %>' style="width:60px"><%# Eval("datejs","{0:d}") %></td>
                                    <td class="tableM" rowspan='<%# Eval("rows") %>' style="width:80px"><a href="#" onclick='<%# "javascript:processMeasure("+Eval("id")+")" %>' ><%# Eval("ManageNo") %></a></td>
                                    <td class="tableM" rowspan='<%# Eval("rows") %>' style="width:100px"><%# Eval("Model") %></td>
                                    <td class="tableM" rowspan='<%# Eval("rows") %>' style="width:100px"><%# Eval("BadItem") %></td></tr><tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                </ItemTemplate>
                                <FooterTemplate>
                                    <td colspan="4">
                                        &nbsp;</td>
                                    </tr></table></FooterTemplate>
                            </asp:Repeater>
                        </div>
    <script language="javascript" type="text/javascript">
    function formOnload()

        if(typeof(document.getElementById("divMeasure"))!='undefined')
        {
            document.getElementById("divMeasure").style.height=document.body.clientHeight-140;
        }
    } ;
    </script>
      

  11.   

    TO:Smile_Wong 
      如您的代码在运行时还是不能控制表头不动而表体动
      

  12.   

    是吗,我的都可以的,而且我的Repeater、GridView、Table等都是用这种方法实现固定表头的不知道你是怎么设置的?
      

  13.   

    一个表格,不过Repeater里还嵌了一个Repeater,但是只有第一个Repeater的表头固定
      

  14.   

    我的是这样的格式,只要h那行不动,其余的是要动的
    ------------------
    h1 | h2| h3 | h4 |
    ---|---|----|----|
       |c11| c12| c13|
       |---|----|----|
    r1 |c21| c22| c23|
    ---|---|----|----|
       |c31| c32| c33|
       |---|----|----|
    r2 |c41| c42| c43|
       |---|----|----|
       |c51| c52| c53|
    ---|---|----|----|
      

  15.   

    TO:Smile_Wong
    可以用了,终于达到想要的效果了,非常感觉你能提供这么好用的代码!
    结贴
      

  16.   

    [Quote=引用 19 楼 smile_wong 的回复:]
    document.getElementById("divMeasure").style.height=document.body.clientHeight-140;
     参数无效???