我想将datagrid中绑定的数据库记录按时间条件显示相应的颜色,怎么做呢?
解决方案 »
- 爬虫程序,经常一个页面一两兆,经常因内存资源没有自动及时清理导致程序崩溃,咋办???
- 如何显示出系统当前的时间?
- wpf项目程序的入口点函数是什么呀?我找不到Main()呀?
- winform 把Panel当作Div+Css 可以吗? 有用过的吗,路过的高手给看看,谢谢!
- 求救!!!关于session的问题,不同用户操作之间的操作分开
- 关于windows窗体的拉伸问题
- 求 .net项目规划管理之类的电子教程 或 书籍
- 请教C#属性问题!如何判断属性赋值失败??急!
- 欢迎有MRP经验的朋友 谢谢
- 急求 医院管理系统代码
- string 类型变成byte型后大小缺字节 怎么解决 谢谢
- 用c#编写的socket程序可以跨网段传输数据么?
例如今天的显示红色,昨天的显示黑色。
private void grd_user_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.Cells[8].Text!="6")
{
e.Item.Attributes.Add("onMouseOver","this.style.backgroundColor ='#f0f0f0'"); }
}
if(e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item )
{
e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
e.Item.Attributes.Add("onmousedown", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
for (int i = 0; i< grdJieGuo.Columns.Count; i++ )
{
e.Item.Cells[i].Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
//e.Item.Cells[i].Attributes.Add("onmousedown", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
e.Item.Cells[i].Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
}
}
<asp:repeater id=list runat=server>
<itemtemplate>
<font color='<%# getcolor((DataBinder.Eval(Container.DataItem,"date_time")).ToString())%>'>
<%# DataBinder.Eval(Container.DataItem,"字段")%>
</font>
</itemtemplate>
</asp:repeater>
后台:
public string getcolor(string d_time)
{
if (Convert.ToDateTime(d_time)>DateTime.now)
{
retrun "red";
}
else
{
return "blue";
}
}