This topic is locked
[SOLVED]

 View Screen - Hide Null fields

5/12/2010 10:32:44 AM
ASPRunnerPro General questions
S
Scruffy author

Is it possible to hide the fields on the view screen where the field value is 'null' ? This would vary from record to record.
TIA

Sergey Kornilov admin 5/13/2010

Just a basic idea - you can use Before Display event of View page:

http://xlinesoft.com/asprunnerpro/docs/before_display.htm
First of all construct and execute SQL Query that retrieves the current record. Then hide certain field blocks if corresponding field is null.
Here is the sample code. Make sure you use correct field and table names.



sql = "select from TableName where KeyColumn=" & Request.QueryString("editid1")

set rstmp = CustomQuery(sql)
xt.assign("Field1_fieldblock",IsNull(rstmp("Field1"))

xt.assign("Field2_fieldblock",IsNull(rstmp("Field2"))

xt.assign("Field3_fieldblock",IsNull(rstmp("Field3"))

...
rstmp.close : set rstmp = nothing
S
Scruffy author 5/13/2010



Just a basic idea - you can use Before Display event of View page:

http://xlinesoft.com/asprunnerpro/docs/before_display.htm
First of all construct and execute SQL Query that retrieves the current record. Then hide certain field blocks if corresponding field is null.
Here is the sample code. Make sure you use correct field and table names.



sql = "select from TableName where KeyColumn=" & Request.QueryString("editid1")

set rstmp = CustomQuery(sql)
xt.assign("Field1_fieldblock",IsNull(rstmp("Field1"))

xt.assign("Field2_fieldblock",IsNull(rstmp("Field2"))

xt.assign("Field3_fieldblock",IsNull(rstmp("Field3"))

...
rstmp.close : set rstmp = nothing



I've added the follow to the view_before event but am still seeing the blank fields, is this correct.. or have i missed something.
I've created a test database with a table called AllDatabases, it contains ID, Field1 and Field2
The code i've entered is
sql = "select * from AllDatabases where ID=" & Request.QueryString("editid1")

set rstmp = CustomQuery(sql)
xt.assign "ID_fieldblock",IsNull(rstmp("ID"))

xt.assign "Field1_fieldblock",IsNull(rstmp("Field1"))

xt.assign "Field2_fieldblock",IsNull(rstmp("Field2"))
rstmp.close : set rstmp = nothing

J
Jane 5/13/2010

Hi,
your code looks correct. It's hard to tell you what's wrong without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

S
Scruffy author 5/14/2010



Hi,
your code looks correct. It's hard to tell you what's wrong without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.


Oops, i'd put the code in view before process, rather than view before display. I've now go the code in the right place, but instead of hiding the null fields it shows null fields and hides the fields with content which is the opposite of what i need to do.

J
Jane 5/14/2010

Hi,
please see my changes below:

if IsNull(rstmp("Field1") then

xt.assign "Field1_fieldblock",false

end if

if IsNull(rstmp("Field2") then

xt.assign "Field2_fieldblock",false

end if

if IsNull(rstmp("Field3") then

xt.assign "Field3_fieldblock",false

end if
S
Scruffy author 5/14/2010



Hi,
please see my changes below:

if IsNull(rstmp("Field1") then

xt.assign "Field1_fieldblock",false

end if

if IsNull(rstmp("Field2") then

xt.assign "Field2_fieldblock",false

end if

if IsNull(rstmp("Field3") then

xt.assign "Field3_fieldblock",false

end if



Jane, many thanks