http://dotnet.aspx.cc/ShowList.aspx?id=1这个页面上,列表使用的是什么控件?datagrid吗?我现在想知道的是鼠标经过时的横条是怎么出现的?就是说每个TR中的代码<tr onmouseover="this.bgColor='#C1D2EE'" bgcolor="oldlace" onmouseout="this.bgColor=document.getElementById('DataGrid1').getAttribute('oldValue')">是怎么加入的,谢谢!

解决方案 »

  1.   

    private void DataGrid1_ItemDataBound(object sender,System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
          if( e.Item.ItemIndex != -1 )
          {
            e.Item.Attributes.Add("onmouseover", "this.bgColor='#C1D2EE'");
            if (e.Item.ItemIndex % 2 == 0 )
            {
              e.Item.Attributes.Add("bgcolor", "#FFFFFF");
              e.Item.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('" + DataGrid1.ClientID + "').getAttribute('singleValue')");
            }
            else
            {
              e.Item.Attributes.Add("bgcolor", "oldlace");
              e.Item.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('" + DataGrid1.ClientID + "').getAttribute('oldValue')");
            }
          }
          else
          {
            DataGrid1.Attributes.Add("oldValue", "oldlace");
            DataGrid1.Attributes.Add("singleValue", "#FFFFFF");
          }
        }