Click here to Skip to main content
15,881,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
when database field is null/empty then corresponding text should become invisible


 I have developed a web page in front page and using vbscript t language and database in MS acess .

in front page I have used dropdown menu which display plant name 

when we select any plant name from list it will display corresponding information on the web page i.e

Plant name: 

Trade name:

Synonyms:

uses : 


my code is like this :b>Plant name :<%=rs1("plantname")%><br />
b>Trade name :<%=rs1("tradename")%><br />
Synonyms   :<%=rs1("synonym1")%> <%=rs1("synonym2")%> <%=rs1("synonym3")%> <%=rs1("synonym4")%> <%=rs1("synonym5")%>
<%=rs1("synonym6")%><br />
Uses<br />
<textarea  readonly="readonly" name="S1" 
        style="width: 322px; height: 246px;"><%=rs1("uses1")%> <%=rs1("uses2")%> <%=rs1("uses3")%></textarea><br>



this code is working fine information on the basis of plant selection is working.

but the text which i have written above as Trade name ,Plant name ,uses etc .

I want that when I select a particular plant from the list and its related information is null/empty then that particular text will also get disappear. means if there is no information then there should be no heading or text for it.

please solve this answer .</br>
Posted

1 solution

To check for null value, you can add codes while retrieving data from database in query.

You can do like...
SQL
SELECT ISNULL(PlantName, '') as PlantName,
       ISNULL(TradeName, '') as TradeName,
       ISNULL(Synonyms, '') as Synonyms,
       ISNULL(uses, '') as uses,
FROM Plant_Details
WHERE PlantId = @PlantId

So, ISNULL checks the first parameter (ex. PlantName) and if it is NULL, then it will return the second parameter, which is blank in this case ('').

Then after getting the values from the DB u can show the same...

Happy coding... :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900