Is this acceptable code?
Posted on 2001-06-18
I get an error : Invalid use of Null: 'CStr'
Here is a copy of the code:
<option value="<%=(rsProgramType.Fields.Item("education").Value)%>" <%if (CStr(rsProgramType.Fields.Item("education").Value) = CStr(RrsLookup.Fields.Item("edu_programtype1").Value)) then Response.Write("SELECTED") : Response.Write("")%>><%=(rsProgramType.Fields.Item("education").Value)%></option>
When I remove the CStr the page seems to load fine. Is it acceptable to remove the CStr from the above code?
There are two tables - one with the choices and the other used to store the value selected. When loading the load if the field is NULL I get the above error. When the field has data, I don't. This form has a lot of dropdowns, that may return blank the first time, but the next visit brings the data back.
Unless there is an easier way to detect a field is with data, I'm sure what to add here...