binding to the opposite of a boolean

3 posts, 0 answers
  1. Tops Software
    Tops Software avatar
    8 posts
    Member since:
    Aug 2012

    Posted 22 Aug 2013 Link to this post

    Hello,
    This should be easy but I am struggling to find a solution. 

    I have a radgrid with a custom edit form template I want to show one of the fields based on the opposite of a boolean field.
    Something like this:

    <tr id="trCloseDate" runat="server" visible='<%# Bind(!"j") %>'>

    I dont think this would ultimately work though as I would need the user to be able to toggle at will. Something in the code behind would work better I think.

    I have tried to do this in the code behind, using the onCheckChanged event but am running into issues as I cant find a way to get the tr control as it is not rendered yet, I believe, since it is later in the table.

    Another weird side issue is that the checkbox is not showing the correct check if I use the changed event.

    Thank you for your time.
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 23 Aug 2013 Link to this post

    Hello,

    Please try with the below code snippet.

    Visible='<%# Eval("j") == false ? true: false %>'

    OR

    Visible='<%# Convert.ToBoolean(Eval("j")) ? false: true %>'


    Let me know if any concern.

    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tops Software
    Tops Software avatar
    8 posts
    Member since:
    Aug 2012

    Posted 23 Aug 2013 Link to this post

    The second one was perfect.

    I should have thought of that Thank you.
Back to Top