我要判断gridview 第三列的值,如果值等于“2009-01-01” 就把这一行变成黄色,请问怎么取到这个值判断呢?
在线等结贴
在线等结贴
解决方案 »
- 求教高手,C#怎样把自己的程序添加到系统右键并获得调用该程序的文件地址及文件名?
- Datagridveiw里如何实现只能输入固定位数数字并且可以Ctrl c Ctrl v?
- 循环删除checklistbox中的项
- datagrid的一个问题解决就给分在线等
- 问一个关于ADO.NET中简单的问题
- format string 能否自定义格式
- C#中判断一个输入是否为整数的函数是什么?
- 怎么改变菜单设计时的外观!
- 如何把一个文件保存在数据库的image字段中
- 二叉树循环高手
- 简单的问题,datagridview的一点小操作
- 【问】为什么 Effective C# 原则11:选择foreach循环 ?for的效率低?
{
string lbl = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "column3"));
if (lbl == "2009-01-01"
{
e.Row.Cells[2].BackColor= Color.Yellow;
}
}
using System.Drawing;
protected void gv_result_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)
{
if (e.Row.Cells[2].Text.Trim() == "2009-01-01")
{
e.Row.Cells[2].BackColor= Color.Yellow;
}
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{ for (int i = -1; i < GridView1.Rows.Count; i++)
{
string lbl = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "你要判断的列名"));
if (lbl == "2009-01-01"
{
e.Row.BackColor= Color.Yellow;
}
}
}
我试过了,绝对正确!