我从数据库中返回一个DATATABLE “dt”赋给 DataGridCiew
 this.dataGridView1.DataSource = dt; 里面有一列 bExclusivity 值是0或1  我想是0的时候在页面上显示“是”1显示“否”
 我现在是这样做的 只能显示0和1 请问该怎么做??
if (this.dataGridView1.Columns["bExclusivity"] != null)
   {
       this.dataGridView1.Columns["bExclusivity"].HeaderText = "是否独占性";
        this.dataGridView1.Columns["bExclusivity"].ReadOnly = true;
    }

解决方案 »

  1.   

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)  
    {  
    if(this.dataGridView1.Columns[e.ColumnIndex].HeaderText =="")  
    {  
    e.Value=object.Equals(e.Value,0))  
    ?"":"";   
    }  

    select case
     
      

  2.   

    直接在sql语句中判断,case when then select t = case  when aaaaa=0 
                             then '是'
                             when aaa
           then   '否'
            end from testBit
      

  3.   

    private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)   
    {   
    if(this.dataGridView1.Columns[e.ColumnIndex].HeaderText =="")   
    {   
    e.Value=object.Equals(e.Value,0))   
    ?"":"";   
    }   
    }  
    select case
     
    一楼能否结合我上边说的写清楚点 谢谢!