Test Menu

  • Commentary
  • Deals
  • Coupons

Dec 14, 2011

Deploying Crystal Reports for Visual Studio 2010

If you're writing an application that uses Crystal Reports for Visual Studio 2010, the steps for deploying the application and getting the report to work are not obvious.  The following steps helped me with deployment.
  1. Download and install the Crystal Reports for Visual Studio 2010 Run-time on the server where application will be deployed.  

  2. Download is herehttp://www.businessobjects.com/jump/xi/crvs2010/us2_default.asp 
  1. Copy C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETClientFiles
  2. Paste to \Inetpub\wwwroot\aspnet_client\system_web\2_0_50727 (or the asp_client folder of the default website).
These steps seem very simple, but for a while I was running the report and getting a blank window.  I noticed a javascript error "bobj is undefined".  That was because I hadn't done steps 2 and 3.  Some searches led me an answer here: http://bytes.com/topic/net/answers/823323-crystal-report-error-bobj-undefined

Crystal Reports - Text or Text Number With Three Decimal Places


This is a Crystal Report formula field.  The requirement is to display the string 'No Data' when the value is null and if it isn't null show the number with three decimal places.To display 'No Data' both parts of the if must be converted to text.

If NumericText ({SupplierStatistic.pHMin}) Then 
    ToText(ToNumber({SupplierStatistic.pHMin}),3)
Else
    'No Data'

Nov 29, 2011

Averages with Linq

Here are two different ways to get the average using Linq.  These examples use a generic list of a class that has a Temperature  property:


Dim avgTemperature = (From c In lst Where c.Temperature IsNot Nothing Select c.Temperature).Average()


Dim avgTemperature = From t In lst Where t.Temperature IsNot Nothing Aggregate Temperature In lst Into Average(t.Temperature)

Nov 28, 2011

Concatenating Static Text to an Eval Expression

This wasn't obvious to me even though it seemed basic.  Full credit goes to the original post on stackoverflow.

I was using a datalist and wanted to concatenate the text "Collection Type: " before the Eval expression.  The only solution I could find was to use a format string.  I favored this solution instead of using the code-behind.

<asp:Label ID="CollectionTypeLabel" runat="server" text='<%#DataBinder.Eval(Container.DataItem, "CollectionType", "Collection Type: {0}")%>' />

Nov 22, 2011

Databound Checklist - Check All by Default


The following code shows an easy way to loop through the list of checkboxes and select each one:


''' <summary>
''' checks all of the checkboxes by default
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Protected Sub chkListParameterSelections_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkListParameterSelections.DataBound


        Try


            For Each li As ListItem In chkListParameterSelections.Items
                li.Selected = True
            Next


        Catch ex As Exception
            ErrorLogging.LogError(ex, "ctrlStatistics.chkListParameters_DataBound")
        End Try


End Sub

Nov 10, 2011

CSS Problem After IFrame Loads

Problem: The CSS is breaking in a web page that includes an iframe in IE8 when the content of the iframe loads.  The page works fine in firefox and chrome.  Other pages without the iframe that use the same CSS file don't have the problem.

Fix: This tag was in the head: 
<meta http-equiv="X-UA-Compatible" content="IE=8" />

It was changed to: 
<meta http-equiv="X-UA-Compatible" content="IE=7" />

Nov 4, 2011

Clear All Textboxes on a Web Form

For Each ctrl As Control In Form.Controls
    If ctrl.GetType.Name = "TextBox" Then 
        Dim tb As TextBox = ctrl tb.Text = String.Empty
    End If 
 Next