Click here to Skip to main content
13,046,480 members (72,491 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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 4-Jul-12 20:51pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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

You can do like...
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... :)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100