这是C#代码         <asp:Repeater id="dlData" runat="server"  >
          <HeaderTemplate>
            <table id="form_eidit" style="margin:0" width="100%" cellpadding="0" cellspacing="0"  border="dashed 1px #cccccc";> 
                <tr>                    <td>件号</td>
                    <td>名称</td>
                    <td>数量</td>
                               
                </tr>          
          </HeaderTemplate>            
          <ItemTemplate>              
            <tr >                <td><%# DataBinder.Eval(Container.DataItem, "materialID")%></td>
                <td><%# DataBinder.Eval(Container.DataItem, "name")%></td>
                <td><%# DataBinder.Eval(Container.DataItem, "quality")%></td>
            </tr>
          </ItemTemplate>            
          <FooterTemplate>        
  </table>
          </FooterTemplate>                      
      </asp:Repeater> 请各位大牛,帮忙解答。
非常感谢。

解决方案 »

  1.   

    在Repeater中加一表格或div<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">  
      <ItemTemplate>  
      <table border="0" cellspacing="0" cellpadding="0" width="100%" runat ="server" id="table1"><tr><td >
      .......
      .......
      </td></tr></table>
      </ItemTemplate>
    </asp:Repeater>ItemDataBound事件:
    add : using System.Web.UI.HtmlControls
    HtmlTable myTable = (HtmlTable)e.Item.FindControl("table1");
      if (myTable != null)
      myTable.Attributes.Add("onclick", "changeColor('" + myTable.ClientID.ToString() + "')");页面js:<script type="text/javascript">
      function changeColor(obj) {
      var myTable = document.getElementsByTagName("table");
        
      for (i = 0; i < myTable.length; i++) {
      if (myTable[i].id == obj)
      document.getElementById(myTable[i].id).style.backgroundColor = "#ff0000";
      else
      document.getElementById(myTable[i].id).style.backgroundColor = "#ffffff";
      }
      }
    </script>
      

  2.   

    itliyi
    为什么试了你的代码,没有任何反应呢?
    请指教,谢谢。
      

  3.   

    taomanman
    那个帖子和我的需求不太一致,谢谢。
      

  4.   

    鼠标经过时变色?主要加这一句话
    <tr onmousemove="this.style.backgroundColor='#0099CC'" onmouseout="this.style.backgroundColor='#ffffff'" >
    <asp:Repeater id="dlData" runat="server" >
      <HeaderTemplate>
      <table id="form_eidit" style="margin:0" width="100%" cellpadding="0" cellspacing="0" border="dashed 1px #cccccc";> 
      <tr>  <td>件号</td>
      <td>名称</td>
      <td>数量</td>
       
      </tr>  
      </HeaderTemplate>  
      <ItemTemplate>  
      <tr onmousemove="this.style.backgroundColor='#0099CC'" onmouseout="this.style.backgroundColor='#ffffff'" >
      <td><%# DataBinder.Eval(Container.DataItem, "materialID")%></td>
      <td><%# DataBinder.Eval(Container.DataItem, "name")%></td>
      <td><%# DataBinder.Eval(Container.DataItem, "quality")%></td>
      </tr>
      </ItemTemplate>  
      <FooterTemplate>  
      </table>
      </FooterTemplate>  
      </asp:Repeater> 
      

  5.   

    http://apps.hi.baidu.com/share/detail/24691935
      

  6.   

    taomanman
    <tr onmousemove="this.style.backgroundColor='#0099CC'" onmouseout="this.style.backgroundColor='#ffffff'" >
    这个确实可以实现鼠标滑过变色,谢谢。
      

  7.   

    <script language="javascript"><!--
        function theObjTable(o,a,b,c){
            var t=document.getElementById(o).getElementsByTagName("tr");
            for(var i=0;i<t.length;i++){
                t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
                t[i].onclick=function(){
                    if(this.x!="1"){
                    }else{
                        this.x="0";
                        this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
                    }
                }
                t[i].onmouseover=function(){
                    if(this.x!="1")this.style.backgroundColor=c;
                }
                t[i].onmouseout=function(){
                    if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
                }
            }
        }
    --></script>
    //senfe("表格名称","奇数行背景","偶数行背景","鼠标经过背景","点击后背景");
      

  8.   

     <ItemTemplate>  
    <tr onmousemove="this.style.backgroundColor='#0099CC'" onmouseout="this.style.backgroundColor='#ffffff'" ><%# DataBinder.Eval(Container.DataItem, "materialID")%></tr>
     </ItemTemplate>  
    这样就好了.
      

  9.   

    yksyuan,谢谢你。
    能否解释下,鼠标单击改变行的颜色是如何实现的?
      

  10.   

    提供一种思路
    单击时把当前行改变颜色,遍历所有行把其他行设默认颜色
    jQuery:
    $("#form_eidit tr").bind("onclick",function(){
        this.style.backgroundColor='#0099CC';
    });
      

  11.   

    yksyuan 谢谢你。
    想实现单击时的颜色变化,你的那段js好像不可以?