如果基于时间与datetime列比较,则更改datalist行背景颜色 [英] Change datalist row background color if based on time compared with datetime column

查看:90
本文介绍了如果基于时间与datetime列比较,则更改datalist行背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个注册页面,其中一个候选人注册,我有一个显示所有候选人注册名称的屏幕(在Datalist控制中)。用户在下一轮等待轮到他,并且可以在显示等待列表上看到他的名字。

i我在sqlserver中有一个带有getdate()函数的datetime列。



从候选人注册时我想改变背景颜色特定行,即如果候选时间超过30分钟,则数据列行的背景颜色应更改为橙色,如果跨越一小时颜色应更改为红色...





我该怎么做



我尝试过:



i一直在与其他论坛进行检查,但没有得到适当的结果。

i am having a registration page where a candidate registers and i am having a screen which displays all the candidates registered names( In Datalist control). the user waits for his turn for the next round and can see his name on display waiting list.
i am having a datetime column with getdate() function in sqlserver .

From the time candidate has registered i want to change background color of particular row i.e if candidate time passes 30 minutes background color of datalist row should be changed to orange and if crosses one hour color should be changes to red..


How do i do this

What I have tried:

i Have been checking with others forums for this but did not get appropriate results.

推荐答案

如果你不需要,可以使用jquery实现这一点保存数据库中的颜色

javascript中有一个setInterval函数,它在每个指定的秒后运行。

你可以按照以下顺序使用该函数

了解setInterval



< a href = https://stackoverflow.com/questions/4511652/looping-through-list-items-with-jquery\">javascript - 使用jquery循环列表项 - Stack Overflow 循环遍历列表视图并获取值





you can achieve this using jquery if you don't need to save the color in database
There is a setInterval function in javascript which runs after every specified second.
you can make use of that function in following order
to know about setInterval

javascript - Looping through list items with jquery - Stack Overflowto loop through list view and get the values


<script>
setInterval(function(){ alert("Hello"); }, 2000);

function changeRowColor(){
 // loop through each row and take the time as string from column
 // compare that time with current time.
 // if time difference is more than x mins or y seconds
 // change the color of row

}

<script>


这篇关于如果基于时间与datetime列比较,则更改datalist行背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆