javascript控制資料視窗行的樣式

來源:互聯網
上載者:User

     <style type="text/css">
   TD.bgstyle { BORDER-TOP: #215dc6 1px solid; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#C7D4F7, EndColorStr=#FFFFFF); COLOR: #215dc6; BORDER-BOTTOM: #215dc6 1px solid; BACKGROUND-COLOR: #e6e6e6 }
   TD.bgstyleleft { BORDER-TOP: #215dc6 1px solid; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#C7D4F7, EndColorStr=#FFFFFF); BORDER-LEFT: #215dc6 1px solid; COLOR: #215dc6; BORDER-BOTTOM: #215dc6 1px solid; BACKGROUND-COLOR: #e6e6e6 }
   TD.bgstyleright { BORDER-RIGHT: #215dc6 1px solid; BORDER-TOP: #215dc6 1px solid; FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#C7D4F7, EndColorStr=#FFFFFF); COLOR: #215dc6; BORDER-BOTTOM: #215dc6 1px solid; BACKGROUND-COLOR: #e6e6e6 }
  </style>
  <script language="JavaScript">
  <!--
  function changein(object)
  {
   object.cells[0].className="bgstyleleft";
   count = object.cells.length;
   for(i = 1;i <= count-1;i++)
   {
    object.cells[i].className="bgstyle";
   }
   object.cells[count-1].className="bgstyleright";
   //document.all("Tblhisname").innertext="aaaa";
   //document.all.Tblhisname.value =object.cells[0].value;
  }
  //-->
  </script>
  <script language="JavaScript">
  <!--
  function changeout(object)
  {
   object.cells[0].className="";
   count = object.cells.length;
   for(i = 1;i <= count-1;i++)
   {
    object.cells[i].className="";
   }
   object.cells[count-1].className="";
  }
  //-->
  </script>

  private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  {
   if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

   {

    string OrderItemID =e.Item.Cells[0].Text;//e.item.cells[0].Text;
    Tblhisname.Text=OrderItemID;
    //添加自訂屬性,當滑鼠移過來時設定該行的背景色為"6699ff",並儲存原背景色
    e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
    //添加自訂屬性,當滑鼠移走時還原該行的背景色
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");

    //MouseOver HighLighting
    e.Item.Attributes.Add("onmouseover","changein(this)");
    e.Item.Attributes.Add("onmouseout","changeout(this)");
    e.Item.Attributes.Add("onclick","window.open('Default.aspx?id=" + e.Item.Cells[0].Text + "');");

 

   }

if( e.Item.ItemIndex != -1 )
{
e.Item.Attributes.Add("onmouseover", "this.bgColor='#C1D2EE'");
e.Item.Attributes.Add("onclick", "document.all.text1.innerText=this.cells[0].innerText;document.all.form1.city.value=this.cells[0].innerText;");
if (e.Item.ItemIndex % 2 == 0 )
{
e.Item.Attributes.Add("bgcolor", "#FFFFFF");
 e.Item.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGrid1').getAttribute('singleValue')");
}
else{
e.Item.Attributes.Add("bgcolor", "oldlace");
 e.Item.Attributes.Add("onmouseout", "this.bgColor=document.getElementById('DataGrid1').getAttribute('oldValue')");
}
}else
{
DataGrid1.Attributes.Add("oldValue", "oldlace");
DataGrid1.Attributes.Add("singleValue", "#FFFFFF");
}
}
#region Web Form Designer generated codeoverride protected void OnInit(EventArgs e)
{//// CODEGEN:該調用是 ASP.NET Web Form設計器所必需的。//InitializeComponent();base.OnInit(e);}



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.