datagrid里判斷列的值,然后顯示不同的顏色 在我datagrid里有一列值我現在想值等于1的時候顯示黑色,否則就顯示紅色怎么做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <html><head><meta http-equiv="Content-Language" content="zh-cn"><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>新建网页 1</title></head><body onload="changeColor()"><script> var bIgnoreHeader = false; //是否忽略第一行 ,ingore=true var bIgnoreFooter = false; //是否忽略最后一行,ingore=true function changeColor() { var tab = document.getElementById("DataGrid1") var rowCount= tab.rows.length; for(var i = 0 ;i<rowCount;i++) { //忽略第一行 if(i==0) if(bIgnoreHeader) continue; //忽略最后一行 if(i==(rowCount-1)) if(bIgnoreFooter) continue; //第n行就是 cell[n-1] if(tab.rows[i].cells[0].innerText=="1") { tab.rows[i].style.backgroundColor="#e4e4de"; } } } </script><table border="1" width="100%" id="DataGrid1"> <tr> <td>2</td> <td> </td> </tr> <tr> <td>1</td> <td> </td> </tr> <tr> <td>1</td> <td> </td> </tr> <tr> <td>3</td> <td> </td> </tr> <tr> <td>1</td> <td> </td> </tr></table></body></html> datagrid1_itemdatabind(){if(e.item.itemtype==listitemtype.item||e.item.itemtype==listitemtype.alteritem){if(e.item.cells[0].text=="1")e.item.backcolor=color.Red;//类似这样的写法}} vs2008自带的asp.net Development Server为什么反应(或者启动)会这么慢 请帮忙看看,为什么Gridview不会更新? dropdownlist取值的问题 网段冲突问题 .net2005中,关于ajax方法的问题. 如何把ArrayList转换为DataTable?? 关于权限设计的一些问题 随机的问题 一个SqlDataSource insert插入数据问题 关于Response.WriteFile() 方法涉及的权限问题 求助, 怎么动态编译某个文件 有没有控件让用户选择日期和时间的?
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body onload="changeColor()">
<script>
var bIgnoreHeader = false; //是否忽略第一行 ,ingore=true
var bIgnoreFooter = false; //是否忽略最后一行,ingore=true
function changeColor()
{
var tab = document.getElementById("DataGrid1")
var rowCount= tab.rows.length;
for(var i = 0 ;i<rowCount;i++)
{
//忽略第一行
if(i==0)
if(bIgnoreHeader) continue;
//忽略最后一行
if(i==(rowCount-1))
if(bIgnoreFooter) continue;
//第n行就是 cell[n-1]
if(tab.rows[i].cells[0].innerText=="1")
{
tab.rows[i].style.backgroundColor="#e4e4de";
}
}
}
</script>
<table border="1" width="100%" id="DataGrid1">
<tr>
<td>2</td>
<td> </td>
</tr>
<tr>
<td>1</td>
<td> </td>
</tr>
<tr>
<td>1</td>
<td> </td>
</tr>
<tr>
<td>3</td>
<td> </td>
</tr>
<tr>
<td>1</td>
<td> </td>
</tr>
</table>
</body></html>
{
if(e.item.itemtype==listitemtype.item||e.item.itemtype==listitemtype.alteritem)
{
if(e.item.cells[0].text=="1")
e.item.backcolor=color.Red;//类似这样的写法
}
}