asp.net gridview设置列的颜色 如题设置gridview列的颜色。例如有数据表1 2 3 4 5 6 7 8 9 10 ···设置1,2列为红色,3,4列白色,5,6列红色,7,8列白色,9,10红色···· 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 js是实现啊window.onload=function(){t = document.getElementById("<%=gridView1.ClientID%>")for(i=0;i<t.rows.length;i++){t.rows[i].cells[0].style.color="red"t.rows[i].cells[1].style.color="red"t.rows[i].cells[2].style.color="#FFFFFF".....}} 用JS实现,熟悉ASP.NET的JavaScript机制 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.Cells[0].Text == "1") e.Row.Cells[0].Attributes.Add("style", "color:Red"); } for (int i = 0; i < GridView1.Rows.Count; i++){ GridView1.Rows[i].Cells[0].ForeColor = System.Drawing.Color.Red; GridView1.Rows[i].Cells[1].ForeColor = System.Drawing.Color.Red;}类似这样写就可以了 那更好办啊window.onload=function(){t = document.getElementById("<%=gridView1.ClientID%>")for(i=0;i<t.rows.length;i++){for(j=0;j<t.rows[i].cells.length;j++)if(j % 2 == 0){t.rows[i].cells[0].style.color="#FFFFFF"}else{t.rows[i].cells[1].style.color="red"}}} 在服务器端使用,这种方法GridView1.Rows[i].Cells[0]有些列是得不到的 请赐教 有没有谁想过把美工做完的静态页面生成ASP.NET的动态页面 ASP.NET如何实现传参无规律? 如何把日期变成(dd-mon-yyyy)这样的格式啊? 请问怎样调用返回的SOAP. SliderExtender的文本框为什么总是显示出来 读取TXT文件问题 ????datagird小问题???? 两窗体间传值问题(菜鸟提问!) 请教各位仁兄,关于crystalreport的问题 关于日期从某月的1日循环到月底,当中的每天都能取到,怎么表示 一句话的事能办到吗?
window.onload=function()
{
t = document.getElementById("<%=gridView1.ClientID%>")
for(i=0;i<t.rows.length;i++)
{
t.rows[i].cells[0].style.color="red"
t.rows[i].cells[1].style.color="red"
t.rows[i].cells[2].style.color="#FFFFFF"
.....
}
}
{
if (e.Row.Cells[0].Text == "1")
e.Row.Cells[0].Attributes.Add("style", "color:Red");
}
{
GridView1.Rows[i].Cells[0].ForeColor = System.Drawing.Color.Red;
GridView1.Rows[i].Cells[1].ForeColor = System.Drawing.Color.Red;
}类似这样写就可以了
window.onload=function()
{
t = document.getElementById("<%=gridView1.ClientID%>")
for(i=0;i<t.rows.length;i++)
{
for(j=0;j<t.rows[i].cells.length;j++)
if(j % 2 == 0){
t.rows[i].cells[0].style.color="#FFFFFF"
}
else{
t.rows[i].cells[1].style.color="red"
}
}
}
GridView1.Rows[i].Cells[0]有些列是得不到的