Asp.net2.0中DataGrid标示值转换

 protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
           if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[8].Text == "0")
            {

                e.Row.Cells[8].Text = "<font color=#0054E3>未受理</font>";
           

            }

            if (e.Row.Cells[8].Text == "1")
            {

                e.Row.Cells[8].Text = "<font color=red>已受理</font>";

            }
            if (e.Row.Cells[9].Text == "0")
            {

                e.Row.Cells[9].Text = "<font color=#47872D>未处理</font>";


            }
            if (e.Row.Cells[9].Text == "1")
            {

                e.Row.Cells[9].Text = "<font color=#0054E3>处理中</font>";


            }
            if (e.Row.Cells[9].Text == "2")
            {

                e.Row.Cells[9].Text = "<font color=red>已处理</font>";


            }
        
            if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
            {
                ((LinkButton)e.Row.Cells[10].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要受理吗?')");
            }

        }
        int i;
        //执行循环,保证每条数据都可以更新
        for (i = 0; i < gv.Rows.Count; i++)
        {
            //首先判断是否是数据行
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#EDF4FC'");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }


       

           }         

posted @ 2008-11-21 17:46  山娃  阅读(110)  评论(0)    收藏  举报