使用asp.net将string中的字符串转换为boolean问题 [英] convert string to boolean issue in gridview using asp.net
本文介绍了使用asp.net将string中的字符串转换为boolean问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在数据库值中,数据类型为String.I在数据库中输入的值如Y或N。如果我想使用asp.net将该值绑定到gridview中的复选框。我正在使用此代码
< ItemTemplate >
< asp:CheckBox ID = chkReimbursable runat = server
< span class =code-attribute> 文本 =' <%#(Convert.ToBoolean(Eval( [GroupFlag])))%> ' / >
< / ItemTemplate >
但我正在接受字符串是未被识别为有效布尔值此问题
请在文本属性中解决此问题
解决方案
无法提供布尔值。
尝试检查属性< asp:CheckBox ID =chkReimbursablerunat =server
Text =your textChecked ='<%#(转换.ToBoolean(Eval([GroupFlag])))%>'/>
你的groupflag值必须为'true'或'1'
In Database value datatype is String.I entered values in database like "Y" or "N". If i want to bind that value into checkbox in gridview using asp.net.I am using this code
<ItemTemplate>
<asp:CheckBox ID="chkReimbursable" runat="server"
Text ='<%# (Convert.ToBoolean(Eval("[GroupFlag]"))) %>'/>
</ItemTemplate>
But i am gettting "String was not recognized as a valid Boolean" this issue
Please resolve this issue
解决方案
in text property u can not provide Boolean value.
try this to checked property<asp:CheckBox ID="chkReimbursable" runat="server" Text="your text" Checked ='<%# (Convert.ToBoolean(Eval("[GroupFlag]"))) %>'/>
your groupflag value must be 'true' or '1'
这篇关于使用asp.net将string中的字符串转换为boolean问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文