Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. IsDBNull is not evaluating correctly

IsDBNull is not evaluating correctly

Scheduled Pinned Locked Moved ASP.NET
questiondocker
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CARisk3
    wrote on last edited by
    #1

    Everytime I try to load a datagrid I get that a dbnull can't be convert to a string. I have included the following on the field that I am trying to convert to a link (with document location and name included). <%#iif (IsDBNull(Container.DataItem("LinkName"))= True, "", ViewDocument(Container.DataItem("LinkName")))%> It always goes to my sub routine ViewDoment() even when the Link Name is null. This works well on a field I'm making visible depending on if this same field is null or not but it won't work for the sub routine. Can anyone explain to me why or tell me what is wrong with the code? Thanks, Carolyn

    If you can’t have fun at work, then why go to work?

    C 1 Reply Last reply
    0
    • C CARisk3

      Everytime I try to load a datagrid I get that a dbnull can't be convert to a string. I have included the following on the field that I am trying to convert to a link (with document location and name included). <%#iif (IsDBNull(Container.DataItem("LinkName"))= True, "", ViewDocument(Container.DataItem("LinkName")))%> It always goes to my sub routine ViewDoment() even when the Link Name is null. This works well on a field I'm making visible depending on if this same field is null or not but it won't work for the sub routine. Can anyone explain to me why or tell me what is wrong with the code? Thanks, Carolyn

      If you can’t have fun at work, then why go to work?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      This would work if you used a decent language.... iif evaluates both sides of the equation if I remember correctly. You should write a method that is passed the data item, and inside that, work out if it's DBNull using an if statement, not iif

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      O 1 Reply Last reply
      0
      • C Christian Graus

        This would work if you used a decent language.... iif evaluates both sides of the equation if I remember correctly. You should write a method that is passed the data item, and inside that, work out if it's DBNull using an if statement, not iif

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        O Offline
        O Offline
        Oakman
        wrote on last edited by
        #3

        Christian Graus wrote:

        You should write a method that is passed the data item, and inside that, work out if it's DBNull using an if statement, not iif

        Anybody who uses iif, even if they know that both results can be evaluated is asking for trouble, IMHO. I never used it in classic VB because it was a library function that always produced a function call instead of inline code. I guess its still available for compatibility, but it leads people to think that they can write the kind of code in the OP. X|

        Jon

        Rob Graham wrote:

        100% subsidies are very popular among the 50% of the population that pays no income tax...

        Soap Box 1.0: the first, the original, reborn troll-less

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups