zoukankan      html  css  js  c++  java
  • 设置datagrid的背影及对单元格进行设置

       //如果是数据项并且是交替项
       if(e.Item.ItemType == ListItemType.Item  || e.Item.ItemType == ListItemType.AlternatingItem)
       {
        //添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
        e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
        //添加自定义属性,当鼠标移走时还原该行的背景色
        e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");

       }
       //如果当前项不为空
       if(e.Item.ItemIndex != -1 )
       {
        //取得当前项的索引值加1,因为项的索引值是从0开始的.
        int orderID = e.Item.ItemIndex+1;
        //设置第一列为的单元格内容为当前项索引值加1
        e.Item.Cells[0].Text = orderID.ToString();

        //如果库存为零,则设置该行的背景色为蓝色
        if((e.Item.Cells[8].Text)=="0.00")
         e.Item.Cells[8].CssClass="ItemStyleRightBoldRed";
       }

  • 相关阅读:
    java小知识点5
    java小知识点4
    java小知识点3
    编程之法:面试和算法心得(寻找最小的k个数)
    389. Find the Difference
    104. Maximum Depth of Binary Tree
    485. Max Consecutive Ones
    693. Binary Number with Alternating Bits
    463. Island Perimeter
    566. Reshape the Matrix
  • 原文地址:https://www.cnblogs.com/hhq80/p/657399.html
Copyright © 2011-2022 走看看