Databindings property - I want to disable true values rather than false values

Discussion in 'ASP .Net' started by Steve, Jan 27, 2006.

  1. Steve

    Steve Guest

    As you know there is a databindings property 'Enabled' for fields in
    the gridview.

    In the custom binding section I have used the expression:
    Eval("myfield"). 'myfield' is a boolean field I have in my database.

    This (obviously) leads to all 'False' fields being disabled and 'True'
    ones being enabled.

    What expression can I used instead of Eval("myfield") for the 'Enabled'
    databindings property to make all 'True' values disabled and all
    'False' values enabled?
    Steve, Jan 27, 2006
    #1
    1. Advertising

  2. have you tried simply negating the value?

    vb.net:
    <%# not eval("myField") %>

    C#
    <%# ! Eval("MyField") %>

    Karl
    --
    http://www.openmymind.net/



    "Steve" <> wrote in message
    news:...
    > As you know there is a databindings property 'Enabled' for fields in
    > the gridview.
    >
    > In the custom binding section I have used the expression:
    > Eval("myfield"). 'myfield' is a boolean field I have in my database.
    >
    > This (obviously) leads to all 'False' fields being disabled and 'True'
    > ones being enabled.
    >
    > What expression can I used instead of Eval("myfield") for the 'Enabled'
    > databindings property to make all 'True' values disabled and all
    > 'False' values enabled?
    >
    Karl Seguin [MVP], Jan 27, 2006
    #2
    1. Advertising

  3. Steve

    Steve Guest

    Karl, Thank a lot!

    That did it! Sorry I couldn't figure that out.

    So I guess I can use any valid vb/c expression? Even if statments?

    Thank you very much!
    Steve, Jan 27, 2006
    #3
  4. Yes, but as things get more complicated, you end up better off calling a
    function that resides in your
    codebehind, or hooking into the ItemDataBound event.

    Both methods are documented:
    http://openmymind.net/index.aspx?documentId=8#4

    Karl
    --
    http://www.openmymind.net/



    "Steve" <> wrote in message
    news:...
    > Karl, Thank a lot!
    >
    > That did it! Sorry I couldn't figure that out.
    >
    > So I guess I can use any valid vb/c expression? Even if statments?
    >
    > Thank you very much!
    >
    Karl Seguin [MVP], Jan 27, 2006
    #4
  5. Steve

    Steve Guest

    Thanks Karl, I'll check out your site to figure it out.

    Thank you.
    Steve, Jan 27, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron Ackerman
    Replies:
    1
    Views:
    5,216
    Aaron Ackerman
    Feb 16, 2004
  2. =?Utf-8?B?UFc=?=
    Replies:
    0
    Views:
    967
    =?Utf-8?B?UFc=?=
    Apr 24, 2006
  3. André
    Replies:
    3
    Views:
    1,584
  4. James
    Replies:
    1
    Views:
    339
    James
    Nov 24, 2006
  5. bdb112
    Replies:
    45
    Views:
    1,337
    jazbees
    Apr 29, 2009
Loading...

Share This Page