• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2038
  • Last Modified:

Report Title on Crystal Report Viewer Visual Studio 2005

How do I set the report title on a report using the viewer control? Its a special field. Is it considered a parameter? If so how do you decide what parameter number it is? I've seen this example:

        ' Set Parameters
        rptFile.SetParameterValue(0, dteIn)

But how do I know what value is which?


0
t1clausen
Asked:
t1clausen
1 Solution
 
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
The report title is a property that you can set.

In the RDC object model, it's:  Report.ReportTitle

You can also design a parameter for the report and set the value of the parameter.
0
 
SpykairCommented:
0
 
t1clausenAuthor Commented:
Report.ReportTitle doesn't work for Visual Studio 2005. Well at least not the way I'm doing it...


As far as the link goes how do I know what parameter item I'm refering to?
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
AlThePal7Commented:
Where are you displaying this title?  What I do is put the Viewer control on a form and set the title of the form (with me.caption="Title"), which I think looks neater.
0
 
t1clausenAuthor Commented:
That might not be a bad idea, but if the user wants to print the report the title is lost. Crystal has a special field built in called report title. In vb you can just set the value to something. For some reason in 2005 I can't find where to do that. This is what I'm doing...


Code behind:
        CrystalReportSource1.Report.FileName = Session("ReportName")
        SqlDataSource1.SelectCommand = Session("ReportFormula")

Main code:
    <form id="form1" runat="server">
    <div>
          <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            ReportSourceID="CrystalReportSource1" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False"/>
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report>
                <DataSources>
                    <CR:DataSourceRef DataSourceID="SqlDataSource1" />
                </DataSources>
            </Report>
        </CR:CrystalReportSource>
   
    </div>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:adrConnectionString2 %>"
            ></asp:SqlDataSource>
    </form>
0
 
t1clausenAuthor Commented:
Got it! I had to actually create a Parameter feild instead of using the built in Report title but it worked!
Code Behind:

    Private Sub RunReport()
        CrystalReportSource1.Report.FileName = Session("ReportName")
        SqlDataSource1.SelectCommand = Session("ReportFormula")
        CrystalReportSource1.Report.Parameters.Item(0).DefaultValue = "Report Title"
    End Sub

Main Code:

<form id="form1" runat="server">
    <div>
          <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            ReportSourceID="CrystalReportSource1" DisplayGroupTree="False" EnableDatabaseLogonPrompt="False"/>
        <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
            <Report>
                <DataSources>
                    <CR:DataSourceRef DataSourceID="SqlDataSource1" />
                </DataSources>
                <Parameters>
                    <CR:ControlParameter ControlID="" ConvertEmptyStringToNull="False" Name="Report Title" PropertyName="" ReportName="" />
                </Parameters>
            </Report>
        </CR:CrystalReportSource>
   
    </div>
        <asp:SqlDataSource ID="SqlDataSource1"  runat="server" ConnectionString="<%$ ConnectionStrings:adrConnectionString2 %>"
            ></asp:SqlDataSource>
    </form>


0
 
t1clausenAuthor Commented:
I found I need to add the table name for the SQL command to work!    

Private Sub RunReport()
        CrystalReportSource1.Report.FileName = Session("ReportName")
        SqlDataSource1.SelectCommand = Session("ReportFormula")
        CrystalReportSource1.Report.DataSources.Item(0).TableName = Session("table name")
        CrystalReportSource1.Report.Parameters.Item(0).DefaultValue = Session("ReportTitle")
    End Sub
0
 
SpykairCommented:
Glad I could help.

Spykair
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now