Asp.net ListView使用技巧2012-01-101、鼠标移到ListView某一行时改变该行的背景色方法前端代码:
<asp:ListView ID="ListView1" runat="server"      onitemdatabound="ListView1_ItemDataBound">      <LayoutTemplate>        <table id="Table1" runat="server" border="0" style="">          <tr runat="server" id="itemPlaceholder" />        </table>      </LayoutTemplate>      <ItemTemplate>        <tr runat="server" id="Tr">          <td>            <%#Eval("ID") %>          </td>          <td>            <%# Eval("name") %>          </td>          <td>            <%# Eval("age") %>          </td>        </tr>      </ItemTemplate>    </asp:ListView>
后台代码:
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)  {    if (e.Item.ItemType==ListViewItemType.DataItem)    {      (e.Item.FindControl("Tr") as HtmlTableRow).Attributes.        Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor="#00A9FF"");      (e.Item.FindControl("Tr") as HtmlTableRow).Attributes.      Add("onmouseout", "this.style.backgroundColor=c");    }  }