IsDBNull is not evaluating correctly
-
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?
-
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?
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.
-
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.
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...