out of curiosity

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Sep 9, 2005.

  1. hey all,

    i have the following 2 scenarios, 1 works the other doesn't:

    this works:

    If IsDBNull(e.Item.DataItem("DateField")) Then
    e.Item.Cells(DATE_APPROVED).Text = String.Empty
    Else
    e.Item.Cells(DATE_APPROVED).Text = "a value"
    End If

    this doesn't work (it appears to execute the false part when the function
    actually returns true in the Command window.)

    textbox1.text=iif(IsDBNull(e.Item.DataItem("DateField")), String.Empty,
    "false part")


    thanks,
    rodchar
    =?Utf-8?B?cm9kY2hhcg==?=, Sep 9, 2005
    #1
    1. Advertising

  2. Be aware that IIf is a method and as such all arguments are evaluated when
    you call this method - i.e., the true and false parts are always evaluated.
    (this is in contrast to the behavior of the ternary or '?' operator in C#,
    which is not a function).
    --
    David Anton
    www.tangiblesoftwaresolutions.com
    Instant C#: VB.NET to C# Converter
    Instant VB: C# to VB.NET Converter
    Instant J#: VB.NET to J# Converter
    Clear VB: Cleans up outdated VB.NET code


    "rodchar" wrote:

    > hey all,
    >
    > i have the following 2 scenarios, 1 works the other doesn't:
    >
    > this works:
    >
    > If IsDBNull(e.Item.DataItem("DateField")) Then
    > e.Item.Cells(DATE_APPROVED).Text = String.Empty
    > Else
    > e.Item.Cells(DATE_APPROVED).Text = "a value"
    > End If
    >
    > this doesn't work (it appears to execute the false part when the function
    > actually returns true in the Command window.)
    >
    > textbox1.text=iif(IsDBNull(e.Item.DataItem("DateField")), String.Empty,
    > "false part")
    >
    >
    > thanks,
    > rodchar
    =?Utf-8?B?RGF2aWQgQW50b24=?=, Sep 10, 2005
    #2
    1. Advertising

  3. so, does that mean that the following should not have worked as intended?

    > > textbox1.text=iif(IsDBNull(e.Item.DataItem("DateField")), String.Empty,
    > > "false part")


    "David Anton" wrote:

    > Be aware that IIf is a method and as such all arguments are evaluated when
    > you call this method - i.e., the true and false parts are always evaluated.
    > (this is in contrast to the behavior of the ternary or '?' operator in C#,
    > which is not a function).
    > --
    > David Anton
    > www.tangiblesoftwaresolutions.com
    > Instant C#: VB.NET to C# Converter
    > Instant VB: C# to VB.NET Converter
    > Instant J#: VB.NET to J# Converter
    > Clear VB: Cleans up outdated VB.NET code
    >
    >
    > "rodchar" wrote:
    >
    > > hey all,
    > >
    > > i have the following 2 scenarios, 1 works the other doesn't:
    > >
    > > this works:
    > >
    > > If IsDBNull(e.Item.DataItem("DateField")) Then
    > > e.Item.Cells(DATE_APPROVED).Text = String.Empty
    > > Else
    > > e.Item.Cells(DATE_APPROVED).Text = "a value"
    > > End If
    > >
    > > this doesn't work (it appears to execute the false part when the function
    > > actually returns true in the Command window.)
    > >
    > > textbox1.text=iif(IsDBNull(e.Item.DataItem("DateField")), String.Empty,
    > > "false part")
    > >
    > >
    > > thanks,
    > > rodchar
    =?Utf-8?B?cm9kY2hhcg==?=, Sep 12, 2005
    #3
    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. =?Utf-8?B?SmF5IEhpbHlhcmQ=?=

    ConfigurationManager and web.config and ASP.NET refresh curiosity

    =?Utf-8?B?SmF5IEhpbHlhcmQ=?=, Apr 5, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    890
    Brock Allen
    Apr 5, 2005
  2. Daisy
    Replies:
    3
    Views:
    4,054
    Steve Horsley
    Sep 12, 2005
  3. Richard
    Replies:
    2
    Views:
    369
    Jacqui or (maybe) Pete
    Jul 10, 2003
  4. Jay
    Replies:
    6
    Views:
    399
    Adam Fineman
    Jul 29, 2003
  5. Replies:
    3
    Views:
    251
    Alex Martelli
    Jun 19, 2006
Loading...

Share This Page