如何在Datagrid中将0更改为False,将1更改为True [英] How Do I Change 0 To False And 1 To True In Datagrid
本文介绍了如何在Datagrid中将0更改为False,将1更改为True的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都知道将数据网格中的当前值从0更改为false?
例如我得到了这个表:
桌上动物
name |颜色|这是敌对的吗? |
牛| W / B | 0 |
我想仅在数据网格中将该值从0更改为False
提前谢谢!
Anyone got any idea about changing a current value from datagrid from 0 to false?
For example i got this table:
table animals
name | color | is it hostile? |
cow | W/B | 0 |
I want to change that value only in datagrid from 0 to "False"
Thanks in advance!
推荐答案
正如RyanDev建议的那样,在它到达表示层之前更改它。
如果它来自数据库,这是一个问题 - 因为虽然SQL支持BIT数据类型并且可以将内容显示为true或false,但它返回1/0结果对于它。
尝试:
As RyanDev suggests, change it before it gets to the presentation layer.
If it comes from a DB, that's a problem - because although SQL supports the BIT datatype and can display the content as "true" or "false" it returns a "1" / "0" result for it.
Try:
SELECT Name,
Color,
CASE WHEN Bool = 1 THEN 'True'
ELSE 'False'
END AS [Is it hostile?]
FROM Animals
但是......显然你从来没有试过过一个带有公牛的田地......:〜
But...clearly you have never tried to cross a field with a bull in it...:~
在字符串查询时我必须这样做:
On string query i had to do:
SELECT if(animal_hostile, 'true', 'false') 'Is it Hostile?'
这篇关于如何在Datagrid中将0更改为False,将1更改为True的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文