Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to convert a string to boolean if I have two different fields (szValue and szDefault Value) in one checkbox??


*.aspx
XML
<asp:templatefield HeaderText="Value">
               <itemtemplate>
                   <asp:CheckBox ID="ckbValue" runat="server"  CssClass="pkchkbox" ></asp:CheckBox>
               </itemtemplate>
           </asp:templatefield>


C#
DataTable dt = new DataTable();

*.aspx.cs
foreach (DataRow row in m_dt.Rows)
{
    if (row[1].ToString() == "Y")
    {
        row[1] = true;

        //row[1] = true;
    }
    else if (row[1].ToString() == "N")
        row[1] = false;
}


please help me. Thank you
Posted
Comments
CodingLover 14-Dec-14 22:43pm    
What you mean by two different fields in one checkbox?
Member 10889447 14-Dec-14 22:53pm    
I have 2 different columns consisting of szValue and szDefaultValue. Which contains the "Y" and "N" so I want to convert a string to boolean in one checkbox is selected based on a column (szValue or szDefaultValue).
CodingLover 15-Dec-14 5:52am    
I agreed with what Sergey Alexandrovich Kryukov says below, you cannot give a meaningful explanation for converting string to boolean. Why can't you use a flag (may be the status of the control) and use it in backend?
Sergey Alexandrovich Kryukov 14-Dec-14 22:49pm    
Makes no sense, at all, converting a string to Boolean, "two different fields", nothing makes sense.
—SA

1 solution

 
Share this answer
 

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