在GridView中让特定的数据列的值小于某个值时背景色改变。

      在GridView控件中增加DataBound事件,

for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            DataRowView mydrv = myds.Tables["AllUsers"].DefaultView[i];
            int iDate = Convert.ToInt32(mydrv["UserId"]);

            if (Convert.ToInt32(iDate) < 200000)
            {
                GridView1.Rows[i].Cells[4].BackColor = System.Drawing.Color.Red;
            }
        }

posted @ 2009-07-20 13:59  iZiYue  阅读(548)  评论(0编辑  收藏  举报
ChinaHDTV.ORG