返回首页

大家好,

我有一个GridView绑定的DataTable。现在列值的基础上,我要着色的特定行,请让我知道该怎么办呢?

感谢
莫哈末Wasif

回答

评论会员:supriyachaladi 时间:2012/02/04

  protected void grdServices_RowDataBound(object sender, GridViewRowEventArgs e)

        {

            {

                if (e.Row.RowType == DataControlRowType.DataRow)

                {

                    if ((string.IsNullOrEmpty(e.Row.Cells[3].Text) != true) || (e.Row.Cells[3].Text != " "))

                    {

                        int result = Convert.ToInt32(e.Row.Cells[4].Text);

                        if (result == 1) e.Row.BackColor = System.Drawing.Color.Aqua;

                        if (result == 2) e.Row.BackColor = System.Drawing.Color.Peru;

                        if (result == 3) e.Row.BackColor = System.Drawing.Color.Azure;

                        if (result == 5) e.Row.BackColor = System.Drawing.Color.BlanchedAlmond;

                        if (result == 6) e.Row.BackColor = System.Drawing.Color.Coral;

                        if (result == 4) e.Row.BackColor = System.Drawing.Color.Cornsilk;

                    }

                }

            }

        }


作为解决方案,标志着如果u得到任何帮助
评论会员:游客 时间:2012/02/04
koolprasad2003:你可以做它的RowDataBound()事件。现在列值的基础上,你可以改变背景色列{C}