一个datagridview 绑定了一张表DB1 ,DB1中有个oppera_type字段 ,
他有四种情况,分别是0,1,8,9.
我现在想在前台显示的时候,datagridview中不显示这四个值,
当oppera_type=0时 前台的datagridview对应列显示:添加
当oppera_type=1时 前台的datagridview对应列显示:删除
当oppera_type=8时 前台的datagridview对应列显示:上料结束
当oppera_type=9时 前台的datagridview对应列显示:上料
同时我又不想更改数据库中的值,请高手帮忙指点一下......

解决方案 »

  1.   

    winform: 可以试试DataGridViewComboColumn列
    asp.net:在数据绑定事件里面处理即可
      

  2.   

            private void button10_Click(object sender, EventArgs e)
            {
                //DataTable数据
                DataTable dt = new DataTable();
                dt.Columns.Add("oppera_type", typeof(string));
                dt.Rows.Add("0");
                dt.Rows.Add("1");
                dt.Rows.Add("8");
                dt.Rows.Add("9");
                dt.Rows.Add("2");
                dt.Rows.Add("5");
                foreach (DataRow dr in dt.Rows)
                {
                    string type = dr["oppera_type"].ToString();
                    switch (type)//转换
                    {
                        case "0":
                            dr["oppera_type"] = "添加";
                            break;
                        case "1":
                            dr["oppera_type"] = "删除";
                            break;
                        case "8":
                            dr["oppera_type"] = "上料结束";
                            break;
                        case "9":
                            dr["oppera_type"] = "上料";
                            break;
                        default:
                            break;
                    }
                }            dataGridView5.DataSource = dt;//绑定        }
      

  3.   

    在SQL处理也行
    select oppera_type=case oppera_type 
    when 0 then '添加'
    when 1 then '删除'
    when 0 then '上料结束'
    when 0 then '上料'
    else oppera_type end
    from DB1
      

  4.   

    select oppera_type=
    case oppera_type 
    when '0' then '添加'
    when '1' then '删除'
    when '8' then '上料结束'
    when '9' then '上料'
    else oppera_type 
            end
    from DB1
      

  5.   

    一样的啊select ,,oppera_type=       --,,之间加上要添加的其它列
        case oppera_type 
        when '0' then '添加'
        when '1' then '删除'
        when '8' then '上料结束'
        when '9' then '上料'
        else oppera_type 
            end
    from DB1
      

  6.   


    select ,  ,oppera_type=      --,,之间加上要添加的其它列 
        case oppera_type 
        when '0' then '添加' 
        when '1' then '删除' 
        when '8' then '上料结束' 
        when '9' then '上料' 
        else oppera_type 
            end 
    from DB1