在DataGrid中有几个BoundColumn绑定到一个数据表里的字段,其中有一个字段名status的值是1或者2,那么在页面相应DataGrid中也会显示1或2,但是我希望如果是1那么显示“连接”,如果是2那么显示“断开”,请问怎么做?

解决方案 »

  1.   

    在Item_DataBound中写
    if(e.Item.Cells[你要显示列的序号].Text=="1")
    {
       e.Item.Cells[你要显示列的序号].Text="连接";
    }
    else
    {
       e.Item.Cells[你要显示列的序号].Text="断开";
    }
      

  2.   

    select case columnname when '1' then '连接'
                            when '2' then '断开'
      end as columnname from tablename
      

  3.   

    在数据源上转换(数据库中)
    select case status when '1' then '连接'
                            when '2' then '断开'
      end as 状态 from yourtable
    然后 用字段 “状态”绑定grid列
      

  4.   

    对,用楼上的sql直接语句转换。
    如果用的是oracle的存储过程,可用decode转换
      

  5.   

    在哪里写,写到Page_Load函数里吗???