This is a migrated thread and some comments may be shown as answers.

Change text at runtime?

4 Answers 402 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 05 Sep 2007, 09:42 PM
Hello (again) -

On my report's page header, I have a text box and when the report is generated, the text value needs to change depending on the item from a drop-down list on the web page.

I have tried a few ways to get this to work but I have not been succesful.  Does anyone know of a way to do this with the report control on a web page?  I can save the drop-down list selected value as a Session variable if necessary.

Thanks
 - will

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Top achievements
Rank 1
answered on 06 Sep 2007, 01:05 PM
Hi Will,

You can add a public property to your report that will expose the value of the TextBox so that it can be set from outside. For example, if the TextBox is called textBox1:

public class MyReport : Report 
         //Code omitted 
        public string MyDynamicValue 
        { 
            set 
            { 
                this.textBox1.Value = value; 
            } 
        } 
         //Code omitted 
 

Then after you create your report and before you show it, you can set this property depending on your session variable:

protected void Page_Load(object sender, EventArgs e) 
{                
    Report report = new MyReport(); 
    report.MyDynamicValue = mySessionVariable; 
    this.ReportViewer1.Report = report; 
}    

Hope this helps.

Rossen
Telerik Reporting Team  
0
Will
Top achievements
Rank 1
answered on 06 Sep 2007, 02:32 PM
This will solve my problem.  I cannot believe I forgot how the other report parameters (for the stored proc) were created and exposed to the calling page. 

Thanks as always for the great help.
0
Ivan
Telerik team
answered on 07 Sep 2007, 09:14 AM
Hi Will,

I have attached a sample solution that covers the case you are asking for. This solution contains three projects:
  1. WebSite - this web site project keeps track of selected comboBox items and reloads the report. The report was reinitialized according to the selection of comboBox (see Default.aspx.cs file for code implementation);
  2. Report1 - this class library project contains a specific report. This report has a ReportType property which you could use to change the textBox item in report's header and to change report's DataSource too (see ReportType property and ReportCS1_NeedDataSource method in Report1CS.cs file);
     
  3. Windows app - this complementary project shows how to deal with this case in a windows forms app.
To build this solution you should fix the references to the Telerik reporting assemblies according to your configuration.
 

Greetings,
Ivan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Will
Top achievements
Rank 1
answered on 07 Sep 2007, 01:57 PM
Thanks Ivan.  This will help too.
Tags
General Discussions
Asked by
Will
Top achievements
Rank 1
Answers by
Rossen Hristov
Top achievements
Rank 1
Will
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or