Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
4.29/5 (3 votes)
See more:
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
XML
<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
Posted
Updated 3-Sep-13 18:45pm
v3
Comments
kishore sharma 4-Sep-13 1:57am    
how can you convert Y to boolean

1 solution

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'
 
Share this answer
 
v2
Comments
krish2013 3-Sep-13 7:55am    
Hii,
I tried that code but i am getting same issue.in my database my value 'T'and 'N'
[no name] 3-Sep-13 8:37am    
dont use 'T' and 'N' use '1' and '0 or 'true' and 'false'' in database as value
Harshil_Raval 3-Sep-13 8:08am    
Hi, as you said your database have value 'T' and 'N'. Then in your sp or query, you must check for this values, if 'Y' then convert to 1 and if 'N' then convert to 0. It may solve your issue.
krish2013 4-Sep-13 0:28am    
Hii,
I used string datatype in database is it corrrect or not
Harshil_Raval 4-Sep-13 1:19am    
No, for this you should use boolean value. change your db field from string to bit

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900