Forums

ASP

This topic is locked

Invalid use of Null: 'CStr'

Posted 05 Apr 2007 14:23:56
1
has voted
05 Apr 2007 14:23:56 Nicola Young posted:
Help,
Using dreamwever 8 and asp to build forms with drop down menu which may contain data and may not, this depends on what a use selects prior to getting to the page.
I know the reason this error is coming up is because there is not data in the database but not sure how to get round this problem.

code below - hope someone can help!
<td width="110" nowrap bordercolor="#00934F"><select name="R3_Comp" class="newdesign" id="R3_Comp" title="<%= AuditEnvironment.Fields.Item("R3_Comp".Value %>">
<%If (Not isNull("R3_Comp") Then If ("- please select -" = CStr("R3_Comp") Then Response.Write("selected=""selected""" : Response.Write(""%>
<option value="<%=(AuditEnvironment.Fields.Item("R3_Comp".Value)%>" <%If (Not isNull("R3_Comp") Then If (CStr(AuditEnvironment.Fields.Item("R3_Comp".Value) = CStr("R3_Comp") Then Response.Write("selected=""selected""" : Response.Write(""%> ><%=(AuditEnvironment.Fields.Item("R3_Comp".Value)%></option>
<option value="YES" <%If (Not isNull("R3_Comp") Then If ("YES" = CStr("R3_Comp") Then Response.Write("selected=""selected""" : Response.Write(""%>>YES</option>
<option value="NO" <%If (Not isNull("R3_Comp") Then If ("NO" = CStr("R3_Comp") Then Response.Write("selected=""selected""" : Response.Write(""%>>NO</option>
<option value="Pending" <%If (Not isNull("R3_Comp") Then If ("Pending" = CStr("R3_Comp") Then Response.Write("selected=""selected""" : Response.Write(""%>>Pending</option>

Replies

Replied 25 Apr 2007 15:50:56
25 Apr 2007 15:50:56 Dimitris Kouris replied:

I think you should try to use the "if, then, else" conditions to validate if the existence of the field value.

For instance where you have,

.... "R3_Comp" title="<%= AuditEnvironment.Fields.Item("R3_Comp".Value %>">

try:

.... "R3_Comp" title="
<%
if AuditEnvironment.Fields.Item("R3_Comp" <> "" then %>

<%= AuditEnvironment.Fields.Item("R3_Comp".Value %>

<%Else%>

<% = NO DATA FOUND (OR SOMETHING ELSE) %>


<% End if %>" ...


Dim

Reply to this topic