473,769 Members | 5,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to hide fields/columns which are null

5 New Member
Hello. I am very bad at ASP and use ASPRunner Pro to write ASP pages for me. I have come across a problem however which I cannot figure out. Quite simply on a list page I have six fields, [G1 Title],[G2Title],[G3Title],[G4Title],[G5Title],[G6Title]. Depending on who has logged in however, not all of these fields will contain a value. Each of these has its own column and is only displayed once via a SELECT DISTINCT statement. In other words [G1 Title] for example is either populated or NULL, it can not be both. All that I want to do is get the ASP page not to show an empty column for [G1 Title] if it is null. I only want the columns for [G1 Title] through to [G6 Title] to display if their respective values are not NULL. Could anybody help me with this? I would be extremely grateful.
Con.
Jun 20 '10 #1
9 3841
jhardman
3,406 Recognized Expert Specialist
show the code that (1)queries the db and (2)builds the table.

Jared
Jun 22 '10 #2
Conor
5 New Member
@jhardman
Hi Jared

As I have said I am very bad at ASP so I am not quite sure even what you mean.

The code for the ASP Page is as follows...

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML {$html_attrs}><HEAD><TITLE>Test</TITLE>
  3. <link REL="stylesheet" href="include/style.css" type="text/css"><!--[if IE]><link REL="stylesheet" href="include/styleIE.css" type="text/css"><![endif]-->{BEGIN style_block}
  4. <STYLE>
  5. #height100{$id} {padding:10px;}
  6. #toplinks_caption{$id} {padding:0px 30px;font-size:12px;font-weight:bold;}
  7. #mastertable_block{$id} {margin-left:50px;margin-top:10px}
  8. #toplinks_block{$id} {width:100%;padding:3px;padding-left:30px}
  9. #toplinks_block{$id} span {padding-left:5px;}
  10. #search_records_block{$id} { padding-left:20px;}
  11. #search_records_block{$id} > * {vertical-align:middle;}
  12. #search_records_block{$id} select {margin:3px 0px;}
  13. #login_block{$id} {padding:10px; margin-bottom:3px}
  14. #login_block{$id} * {margin-left:5px; padding:5px 0px;}
  15. #menu_block{$id} {padding:10px;}
  16. #menu_block{$id} * {list-style-type:none;}
  17. #menu_block{$id} IMG {vertical-align:middle;}
  18. #records_block{$id} {margin-left:203px;}
  19. #record_controls{$id} {padding:10px 10px;}
  20. #record_controls{$id} span {padding-left:10px;}
  21. #recordcontrolsadd_block{$id} {padding:10px 10px;border: solid; border-width: 1px; border-color: #C0C0C0;}
  22. #recordcontrolsadd_block{$id} span {padding-left:10px;}
  23. #grid_block{$id} {border:solid 1px #C0C0C0;}
  24. .grid_recordheader{$id} {padding:0 5px 5px;vertical-align:top;}
  25. .grid_recordheader{$id} * {margin:0px 5px; vertical-align:top;}
  26. body {margin:0px;padding:0px;}
  27. </STYLE>
  28. {END style_block}
  29. <META name=GENERATOR content="MSHTML 8.00.7600.16588"></HEAD>
  30. <BODY {$bodyattrs} marginwidth="0" marginheight="0">{BEGIN body}
  31. <DIV id="height100{$id}">{$header} 
  32. {BEGIN toplinks_block}<DIV id="toplinks_block{$id}">&nbsp;<FONT 
  33. size=+0><B>Test</B></FONT> <SPAN id="login_block{$id}">Logged on 
  34. as&nbsp;<B>{$username}</B>&nbsp; <A 
  35. href="login.asp?a=logout">Log out</A> </SPAN>{BEGIN asearch_link}<SPAN><A 
  36. href="Test_search.asp">Advanced search</A></SPAN>{END asearch_link} </DIV>{END toplinks_block}
  37. <DIV id="recordcontrolsadd_block{$id}" class=shade>{BEGIN search_records_block}<SPAN id="search_records_block{$id}" class=shade>{BEGIN searchform}<SPAN id="searchform{$id}" class=shade><B>Search for: </B>&nbsp;&nbsp;&nbsp; {BEGIN searchform_field}<SELECT id="ctlSearchField{$id}"> <option value="">Any field</OPTION> <option value="ID" {$ID_searchfieldoption}>ID</OPTION> <option value="G1 Title" {$G1_Title_searchfieldoption}>G1 Title</OPTION> <option value="G2 Title" {$G2_Title_searchfieldoption}>G2 Title</OPTION> 
  38.   <option value="G3 Title" {$G3_Title_searchfieldoption}>G3 Title</OPTION> <option value="G4 Title" {$G4_Title_searchfieldoption}>G4 Title</OPTION> <option value="G5 Title" {$G5_Title_searchfieldoption}>G5 Title</OPTION> <option value="G6 Title" {$G6_Title_searchfieldoption}>G6 Title</OPTION></SELECT>{END searchform_field} &nbsp; {BEGIN searchform_option}<SELECT id="ctlSearchOption{$id}"> <option value="Contains" {$Contains_searchtypeoption}>Contains</OPTION> <option value="Equals" {$Equals_searchtypeoption}>Equals</OPTION> <option value="Starts with ..." {$Starts_with_____searchtypeoption}>Starts with ...</OPTION> <option value="More than ..." {$More_than_____searchtypeoption}>More than ...</OPTION> <option value="Less than ..." {$Less_than_____searchtypeoption}>Less than ...</OPTION> 
  39.   <option value="Equal or more than ..." {$Equal_or_more_than_____searchtypeoption}>Equal or more than ...</OPTION> 
  40.   <option value="Equal or less than ..." {$Equal_or_less_than_____searchtypeoption}>Equal or less than ...</OPTION> 
  41.   <option value="Empty" {$Empty_searchtypeoption}>Empty</OPTION></SELECT>{END searchform_option} &nbsp; {BEGIN searchform_text}<INPUT {$searchfor_attrs}>{END searchform_text} &nbsp; {BEGIN searchform_search}<INPUT class=button value=Search type=button {$searchbutton_attrs}>{END searchform_search} 
  42. &nbsp; {BEGIN searchform_showall}<INPUT class=button value="Show all" type=button {$showallbutton_attrs}>{END searchform_showall} 
  43. </SPAN>{END searchform}{BEGIN details_block}<SPAN>Details found: <B>{$records_found}</B>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>{END details_block} 
  44. {BEGIN pages_block}<SPAN>Page <B>{$page}</B> of <B>{$maxpages}</B></SPAN>{END pages_block} 
  45. &nbsp;&nbsp;&nbsp;&nbsp; {BEGIN recordspp_block}<SPAN id="recordspp_block{$id}">Records Per Page: <SELECT {$recordspp_attrs}> 
  46.   <option value="10" {$rpp10_selected}>10</OPTION> <option value="20" {$rpp20_selected}>20</OPTION> <option value="30" {$rpp30_selected}>30</OPTION> <option value="50" {$rpp50_selected}>50</OPTION> <option value="100" {$rpp100_selected}>100</OPTION> <option value="500" {$rpp500_selected}>500</OPTION></SELECT> </SPAN>{END recordspp_block}</SPAN>{END search_records_block}</DIV>
  47. {BEGIN record_controls}<DIV id="record_controls{$id}"></DIV>{END record_controls}
  48. <DIV id="usermessage{$id}" class=message></DIV>
  49. {BEGIN grid_block}<TABLE style="WIDTH: 100%" id="grid_block{$id}" border=0 cellSpacing=2 cellPadding=3 name="maintable">
  50.   <TBODY>
  51.   {BEGIN grid_header}<TR vAlign=top {$gridHeader_attrs}>{BEGIN record_header}
  52.     {BEGIN ID_fieldheadercolumn}<TD class=blackshade>{BEGIN ID_fieldheader}<A class=blackshade 
  53.       {$ID_orderlinkattrs}>ID</A> {END ID_fieldheader}</TD>{END ID_fieldheadercolumn}
  54.     {BEGIN G1_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G1_Title_fieldheader}<A class=blackshade 
  55.       {$G1_Title_orderlinkattrs}>G1 Title</A> {END G1_Title_fieldheader}</TD>{END G1_Title_fieldheadercolumn}
  56.     {BEGIN G2_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G2_Title_fieldheader}<A class=blackshade 
  57.       {$G2_Title_orderlinkattrs}>G2 Title</A> {END G2_Title_fieldheader}</TD>{END G2_Title_fieldheadercolumn}
  58.     {BEGIN G3_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G3_Title_fieldheader}<A class=blackshade 
  59.       {$G3_Title_orderlinkattrs}>G3 Title</A> {END G3_Title_fieldheader}</TD>{END G3_Title_fieldheadercolumn}
  60.     {BEGIN G4_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G4_Title_fieldheader}<A class=blackshade 
  61.       {$G4_Title_orderlinkattrs}>G4 Title</A> {END G4_Title_fieldheader}</TD>{END G4_Title_fieldheadercolumn}
  62.     {BEGIN G5_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G5_Title_fieldheader}<A class=blackshade 
  63.       {$G5_Title_orderlinkattrs}>G5 Title</A> {END G5_Title_fieldheader}</TD>{END G5_Title_fieldheadercolumn}
  64.     {BEGIN G6_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G6_Title_fieldheader}<A class=blackshade 
  65.       {$G6_Title_orderlinkattrs}>G6 Title</A> {END G6_Title_fieldheader}</TD>{END G6_Title_fieldheadercolumn}{END record_header}</TR>{END grid_header}
  66.   {BEGIN grid_row}<TR vAlign=top {$rowattrs} {$rowstyle}>{BEGIN grid_record}
  67.     {BEGIN ID_fieldcolumn}<TD vAlign=middle align=left {$ID_style}>{$ID_value} </TD>{END ID_fieldcolumn}
  68.     {BEGIN G1_Title_fieldcolumn}<TD vAlign=middle align=left {$G1_Title_style}>{$G1_Title_value} </TD>{END G1_Title_fieldcolumn}
  69.     {BEGIN G2_Title_fieldcolumn}<TD vAlign=middle align=left {$G2_Title_style}>{$G2_Title_value} </TD>{END G2_Title_fieldcolumn}
  70.     {BEGIN G3_Title_fieldcolumn}<TD vAlign=middle align=left {$G3_Title_style}>{$G3_Title_value} </TD>{END G3_Title_fieldcolumn}
  71.     {BEGIN G4_Title_fieldcolumn}<TD vAlign=middle align=left {$G4_Title_style}>{$G4_Title_value} </TD>{END G4_Title_fieldcolumn}
  72.     {BEGIN G5_Title_fieldcolumn}<TD vAlign=middle align=left {$G5_Title_style}>{$G5_Title_value} </TD>{END G5_Title_fieldcolumn}
  73.     {BEGIN G6_Title_fieldcolumn}<TD vAlign=middle align=left {$G6_Title_style}>{$G6_Title_value} </TD>{END G6_Title_fieldcolumn}{END grid_record}</TR>{END grid_row}</TBODY></TABLE>{END grid_block}
  74. {BEGIN pagination_block}<DIV class=toplist align=center>{$pagination}</DIV>{END pagination_block}
  75. {BEGIN message_block}<DIV class=toplist align=center valign="middle"><B>{$message}</B></DIV>{END message_block}{$footer} </DIV>{END body}</BODY></HTML>

The query is just SELECT * FROM Test but I'm not sure if that's what you mean by the code that queries the db.

Many Thanks

Con
Jun 22 '10 #3
Conor
5 New Member
@jhardman
Hi Jared
I just wondered if you had had any thoughts on this? It is giving me a real headache.
Thanks
Con
Jun 23 '10 #4
viktorka
26 New Member
Why don't you try using isnull function.
Example

strValue = ""
if not isnull(rst.fiel d("Column1")) then strValue = rst.field("Colu mn1")
Jun 24 '10 #5
jhardman
3,406 Recognized Expert Specialist
I don't recognize the code at all, it doesn't look like asp to me. What development environment are you using?

Jared
Jun 29 '10 #6
Conor
5 New Member
@jhardman
Hi Jared
It is ASPRunner Pro. So far I have come up with...

if IsNull(("G2")) or IsEmpty ("G2") or ("G2")="" or len("G2")>0 then
xt.assign "G2_fieldheader column",false
xt.assign "G2_fieldcolumn ",false
end if

but this just gets rid of the G2 header and its column whether the value for G2 is null or not. It is as if none of the above if conditions actually mean a NULL value in the database.

Con.
Jun 29 '10 #7
viktorka
26 New Member
@jhardman
This is classic ASP.
isnull is a function (VBscript and Visual Basic the same) that verifies a variable/field for a NULL
Jun 29 '10 #8
Conor
5 New Member
@viktorka
Yes but how do I use it?
Con.
Jun 29 '10 #9
jhardman
3,406 Recognized Expert Specialist
@viktorka
no, I recognize isnull, that's fine, what I don't recognize is
Expand|Select|Wrap|Line Numbers
  1. #    {BEGIN G1_Title_fieldheadercolumn}<TD class=blackshade>{BEGIN G1_Title_fieldheader}<A class=blackshade 
  2. #       {$G1_Title_orderlinkattrs}>G1 Title</A> {END G1_Title_fieldheader}</TD>{END G1_Title_fieldheadercolumn}
This does not look like ASP classic, or ASP.NET. I guess it could just be place-holders for a wysiwyg editor, but this doesn't show how you are connecting to the db.

In asp this code usually looks something like this:
Expand|Select|Wrap|Line Numbers
  1. dim objConn, objRS, strQuery
  2. set objConn = server.createobject("adodb.connection")
  3. objConn.open "DSN=myDSN;UID=myUser;pwd=myPwd"
  4. set objRS = server.createobject("adodb.recordset")
  5. strQuery = "SELECT * FROM myTable"
  6. objRS.open strQuery, objConn
This is the code I'm looking for that queries the db. The code that builds the table is going to look something like this:
Expand|Select|Wrap|Line Numbers
  1. <table><tr>
  2. <%
  3. for each x in objRS.fields
  4.    response.write "<th>" & x & "</th>" & vbNewLine
  5. next %>
  6. </tr>
  7. <%
  8. do until objRS.eof
  9.    response.write "<tr>"
  10.    for each x in objRS.fields
  11.       response.write "<td>" & objRS(x) & "</td>" & vbNewLine
  12.    next
  13.    response.write "</tr>"
  14.    objRS.moveNext
  15. loop %>
  16. </table>
  17.  
Jared
Jun 30 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
22924
by: Aad Aldus | last post by:
Ik have created an index on a date field. 99% of all data in the table has a filled in date. 1 % is NULL When I do a select with clause ... WHERE ADATE IS NULL, Oracle does not use the index. Is this correct? or How can I force Oracle to use the index. Kind reagrds, Aad.
10
13459
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group related to checkboxes. Thanks!!!
5
1492
by: Shane Story | last post by:
I have a dataset with two tables. I make data view of each table, connect the parent table to one data grid and the child table to the other datagrid, with a row filter, that gets set when a user clicks a row in the parent. I have PK/FK in the tables to know what to display. I want to hide the PK/FK columns in the U/I, but still use them.
2
11701
by: jeet_sen | last post by:
Hi, I have created a table colelcting data from an XML source. After I built the whole table I ahve given user options to filter out columns from the table. For this I have collected all the column values of the table in a select list box. Depending on what user selects from the selct list I am displaying the corresponding columns and hiding the columns which the user has not selected fromt the list.
1
1650
by: phillip.s.powell | last post by:
I'm having the most bizarre problem with PHP/MySQL that I've ever faced and it's an urgent matter (of course) to try to fix it ASAP. We have one record inserted into a table with 75 columns, whereby half of the columns are not-null, but for some bizarre reason, the fields are null. The rest of the columns that are null are completely scrambled (e.g. "first_name" is in "address2", "fax" is in "url", "url" is in "last_name", etc.) This...
3
8466
by: mudassir368 | last post by:
--This is the html code <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateField HeaderText="Agent Name"> <ItemTemplate> <asp:Label ID="lblagentname" runat="server" Text='<%#Bind("AgentName") %>'></asp:Label>
2
1250
by: Curious | last post by:
I have a derived class (DistributionItem) that contains a few members. Now I have a binding list of instances of this class to be displayed in a grid. However, extra columns are displayed from the parent class (IWorkerItemBase). How can I hide those members from the parent class in the grid? FYI, my code is below:
10
16712
by: mulamootil | last post by:
Is there a way to hide fields in a report that do not have any data. I have few fields that have images and I would like to hide them as well whenever there is none. I am using Access 07.
6
2282
by: KPR1977 | last post by:
In my Access Database in Table1, I have one record that looks something like this. (eg. "fldProd" represents field name, while "Apple" represents field value.) fldProd - Apple (text value) fldPIO - CF (text value) fldFam - 1 (text value) fldSer - 2 (text value) fldTra - 3 (text value) fldInt - LZ (text value) fildQty - 5 (integer value) The MasterTable looks like this.
2
7164
by: rywags11 | last post by:
Hello, Can anyone help me figure out how to show/hide fields based on information entered in other fields in a form in Access 2007? What I'm looking to do is: When a selection from a drop down is chosen, hidden Yes/No fields (check boxes) that apply to that specific information appear and can be updated by users. The other Yes/No fields that do not apply to the chosen selection remain hidden. I need to be able to do this for all the...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3959
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.