Forums
This topic is locked
Display text in place of null value
Posted 02 Feb 2008 01:05:11
1
has voted
02 Feb 2008 01:05:11 Gary Stockton posted:
I would like to display a static comment "No Hints On File" if a user's password hint is left blank in database. Currently I have a <%=(rsThisUser.Fields.Item("PasswordHint".Value)%> output to the screen, but if there is no hint in the field for their record (a null in the database) the cell in the table has no value. Replies
Replied 03 Feb 2008 02:47:15
03 Feb 2008 02:47:15 Javier Castro replied:
Try This:
<% If (rsThisUser.Fields.Item("PasswordHint".Value) = "" Then %>No hints on file<% Else %><%=(rsThisUser.Fields.Item("PasswordHint".Value)%><% End If %>
Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS
<% If (rsThisUser.Fields.Item("PasswordHint".Value) = "" Then %>No hints on file<% Else %><%=(rsThisUser.Fields.Item("PasswordHint".Value)%><% End If %>
Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS
Replied 04 Feb 2008 21:13:52
04 Feb 2008 21:13:52 Gary Stockton replied:
I tested the recommendation, but all we get when a null is tested is a collapsed table cell.
Replied 05 Feb 2008 10:38:53
05 Feb 2008 10:38:53 Alan C replied:
Another way to handle it might be to set a default value on the database table, such as 'No password hint has been stored' then when the record is created that will automatically go into the field but get overwritten when a hint in entered, that way you don't need to test
Replied 06 Feb 2008 20:31:18
06 Feb 2008 20:31:18 Javier Castro replied:
I just did something similar and worked like a charm.
Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS
Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS