Click here to Skip to main content
15,900,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:TemplateField  HeaderStyle-VerticalAlign="Top" HeaderText="Approved" HeaderStyle-Font-Bold="true" SortExpression="Approved">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkApprove" runat="server" Text="Approve" Visible='<% getBoolStatus(Convert.ToInt32(Eval("Approved"))) %>'></asp:LinkButton>
                                            <asp:Label ID="lblApproved" runat="server" Text="Approved" Visible='<% getBoolStatus(Convert.ToInt32(Eval("Approved"))) %>'/>
                                        </ItemTemplate>
                                        </asp:TemplateField>




I have to make label and link button True or False according to tha value retrieved from database.This is getBoolStatus method which i am calling.
C#
public bool getBoolStatus(int BoolStatus)
        {
            bool status;
            switch (BoolStatus)
            {
                case 1:
                    status = true;
                    break;
                default:
                    status = false;
                    break;
            }
            return status;
        }



I am getting following error

Cannot create an object of type 'System.Boolean' from its string representation '<% getBoolStatus(Convert.ToInt32(Eval("Approved"))) %>' for the 'Visible' property.

Please help me...
Posted
Comments
rahulbhadouria 13-Apr-12 8:21am    
Approved field is not boolean in database its in INTEGER,like 0 or 1.

1 solution

If the Approved field is a boolean value in the database why are you trying to convert it to an Int just to convert it back to a boolean?
 
Share this answer
 
Comments
rahulbhadouria 13-Apr-12 8:21am    
Approved field is not boolean in database its in INTEGER,like 0 or 1.
[no name] 13-Apr-12 8:30am    
Then why try to convert it to an int before sending to this method? Pass the value in, then convert it as necessary. You will then be able to debug.
rahulbhadouria 13-Apr-12 8:33am    
thank I am done.....

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