我是用的repeater绑定的数据,想要实现光棒效果..
可是却不知道怎么做,还请高手们指教!!!!

解决方案 »

  1.   

        //光棒效果
        protected void GridViewInBox_RowCreated(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {            e.Row.Attributes.Add("OnMouseOver", "this.style.background='#349CF4'");            int s = Convert.ToInt32(e.Row.RowIndex.ToString());
                if (s % 2 == 0)
                    e.Row.Attributes.Add("OnMouseOut", "this.style.background='#EEEEEE'");
                else
                    e.Row.Attributes.Add("OnMouseOut", "this.style.background='#DCDCDC'");
            }
        }
      

  2.   

    这是gridview的... 在repeater里面不能用!!!
      

  3.   

    就不能自己变通一下,把这代码加载repeater里么.......
      

  4.   

    Repeater太灵活了,你想用什么表示Repeater最终显示在客户端的东西?
    <ul><li>?
    <table>?
    ?
      

  5.   

    这个非要用在repeater控件里面写代码吗?
    在.css文件里加个样式不就可以拉吗,
      

  6.   

    很简单,定义个样式就完了:
    <ItemTemplate>
            <tr onmouseover="this.style.backgroundColor='#B9D1F3'" onmouseout="this.style.backgroundColor='#ffffff'">
            <td align="center"><%#DataBinder.Eval(Container.DataItem, "字段1")%></td>
            <td align="center"><%#DataBinder.Eval(Container.DataItem, "字段2")%></td>
            <td align="center"><%#DataBinder.Eval(Container.DataItem, "字段3")%></td>
            ...
            </tr>
            </ItemTemplate>
      

  7.   

    一句CSS而已
    比如在<li>标记里我们可以这么些li{background-color:#000000} --鼠标不移动到li上的的效果
    li:hover{background-color:#FFFFFF} --鼠标移动到li上的的效果当然IE7以下{不包含IE}不支持非a标记以外的hover样式,你要用的话要写自定义样式,但我估计没人用IE6之类的了,流行的FF和Opera几个版本都很好的支持
      

  8.   

    看来我猜对了,呵呵就是用onmouseout 和onmouseover 事件<tr onmouseover="this.style.backgroundColor='#000'" onmouseout="this.style.backgroundColor='#fff'"> 
      

  9.   

     //repeater鼠标悬停变色
       var se; 
       function myrepeaterse(id)
       {
            se= id.style.backgroundColor;
            id.style.backgroundColor='#FFFFCC';
       }
       function myrepeaterses(id)
       {
            id.style.backgroundColor=se;
       }    <tr style="background-color:#EBEBEB" onmouseover="myrepeaterse(this)" onmouseout="myrepeaterses(this)">
      

  10.   

    <ItemTemplate> 
            <tr onmouseover="this.style.backgroundColor='#B9D1F3'" onmouseout="this.style.backgroundColor='#ffffff'"> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段1")%> </td> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段2")%> </td> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段3")%> </td> 
            ... 
            </tr> 
            </ItemTemplate>
    <AlternatingItemTemplate>
    //更改onmouseover onmouseout 顔色就可以了。
            <tr onmouseover="this.style.backgroundColor='#B9D1F3'" onmouseout="this.style.backgroundColor='#ffffff'"> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段1")%> </td> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段2")%> </td> 
            <td align="center"> <%#DataBinder.Eval(Container.DataItem, "字段3")%> </td> 
            ... 
            </tr> 
    </AlternatingItemTemplate
      

  11.   

    大哥,这个不是Repeater的吧?