替换GridView指定列的值的显示

来源:互联网 发布:淘宝充值流量如何退款 编辑:程序博客网 时间:2024/04/28 02:00
 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string text = e.Row.Cells[5].Text.ToString();//下标从0开始
                if (text.Equals("1"))
                {
                    text = "<span style='color:green'>已处理</span>";//修改指定列的内容
                }
                else if (text.Equals("0"))
                {
                    text = "未处理";
                }
                else
                {
                    text = "未知";
                }
                e.Row.Cells[5].Text = text;
          

//当值很多的情况下用Switch语句

//替换Object_Class
                string txt4 = e.Row.Cells[4].Text.ToString();
                switch (txt4)
                {
                        case "100":
                        txt4 = "OMC"; break;

                        case "102":
                        txt4 = "HLR"; break;

                        case "121":
                        txt4 = "SGSN"; break;

                        case "122":
                        txt4 = "GGSN"; break;

                        case "126":
                        txt4 = "PCU"; break;

                        case "130":
                        txt4 = "MSC Server"; break;

                        case "131":
                            txt4 = "MGW"; break;

                        case "200":
                        txt4 = "BSC"; break;

                        case "201":
                        txt4 = "SITE"; break;

                        case "300":
                        txt4 = "CELL"; break;

                        case "9200":
                        txt4 = "RNC"; break;


                    case "9201":
                        txt4 = "NodeB"; break;
                    case "9300":
                        txt4 = "UltraCell"; break;
                    default:
                        break;
                }
                e.Row.Cells[4].Text = txt4;

}

原创粉丝点击