近来做个图书管理,在查询借阅的情况,一本书有个借阅期限,借阅时间到了这条记录显示为红色.如何做啊?

解决方案 »

  1.   

    ItemDataBound事件中
    e.item.cells[日期的位置].text与你的过期日期做比较,
    过期就e.item.cells[日期的位置].ForeColor=Color.Red;
    OK
      

  2.   

    dg_itemdatabind()
    {
      if(借阅期限==dateime.now)
      {
        e.item.style.add("color:red");
      }
    }
      

  3.   

    在 绑定事件中
    if(到期){
     e.Item.Cells[].Text="<font color='red'>"+ e.Item.Cells[].Text+"</font>"
    }
      

  4.   

    月儿清清blog里有,楼主自己找找!
      

  5.   

    protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {            
                // 正在提供数据绑定信息的数据源项
                DataRowView drv = e.Item.DataItem as DataRowView;            
                DateTime yourBorrowExpiration;
                // ..
                if (((DateTime)drv["借阅期限"]) > yourBorrowExpiration) {
                    int cellIndex = 0; // 指定单元格
                    e.Item.Cells[cellIndex].Attributes["style"] = "color:red";
                }
            }
        }
      

  6.   

    Jinglecat 正解。用e.Item.Cells[cellIndex].Attributes这个比较好。
      

  7.   

    这条记录显示为红色
    -------------------
    你们是怎样理解的~~~据我理解是一个tr,是一item,并非是一cell...
      

  8.   

    谢谢大家,我现在想显示整条记录为红色,DataGrid如何做