This is the first time I've ever used Crystal Reports, and it shows.
In a seperate page, I select a row from a gridview and click a button to print that particular report.
The Querystring passes that value, the contract number, to the report page.
In the rpt, I have a database field ContractNumber and have created a Crystal Reports parameter, @ContractNumber, and associated those in the record selection formula.
The associated code is:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim crystalReport As New ReportDocument() crystalReport.Load(Server.MapPath("FC15ContractPrint.rpt")) CrystalReportViewer1.ReportSource = crystalReport HiddenField1.Value = Request.QueryString("ContractNumber") Dim crParameterFieldDefinitions As ParameterFieldDefinitions Dim crParameterFieldDefinition As ParameterFieldDefinition Dim crParameterValues As New ParameterValues Dim crParameterDiscreteValue As New ParameterDiscreteValue crParameterDiscreteValue.Value = HiddenField1.Value crParameterFieldDefinitions = crystalReport.DataDefinition.ParameterFields() crParameterFieldDefinition = crParameterFieldDefinitions.Item("@ContractNumber") crParameterValues = crParameterFieldDefinition.CurrentValues crParameterValues.Clear() crParameterValues.Add(crParameterDiscreteValue) crParameterFieldDefinition.ApplyCurrentValues(crParameterValues) CrystalReportViewer1.RefreshReport() End Sub
It keeps asking me to manually input the parameter, though.