Interview Question in SQL Server Reporting Services (SSRS)


 

Interview Question :: Cleanest way to convert null values to zeros using Sql Server Reporting Services 2005


I want to know all the possible ways to convert null values to zeros in Textbox controls using Sql Server Reporting Services 2005.
I know I could use isnull(columnName,0) in my T-SQL select statement, but that's ugly. I can also use some function in the Value property turning this: =Fields!TranNo.Value into something like this: =cint(Fields!TranNo.Value). Is there anyway to use the Format property? I don't know much about the .NET code that you can write in a report. Is it only capable of Functions and Subs that get called from field values, or could I code some kind of event handler like in an MS Access report? OnReportLoad kinda thing? If I could do that, could I loop through the rows and columns of the dataset and swap out the nulls for zeros there?
Thank you for your help! I've been trying to figure this out and going crazy!
Answers to "Cleanest way to convert null values to zeros using Sql Server Reporting Services 2005"
RE: Cleanest way to convert null values to zeros using Sql Server Reporting Services 2005?

use javascript in your forms page. using the onsubmit, enumerate every field and set the value if null. The code has some spaces in the document.x. ....yahoo doesn't like certain string groupings and truncates it....you will need to remove the spaces



if document.formname.fieldname = ""

{document. formname. fieldname=0}



You can do some more validation too......assuming you don't want negative numbers.....

if document. formname. fieldname < 0

{//Do something here, maybe a messagebox saying no negative number are allowed

//Change the color

document. formname.fieldname. style. backgroundcolor = "yellow";

//Set focus back on the field

document. formname. fieldname. focus();

//prevent the form from being submitted

return false; }
 
Vote for this answer ::  
Update Alert Setting