K. Taylor
K. Taylor

Reputation: 23

Altering a value in a rdlc report through .aspx.cs C# code

First off I am using Microsoft Visual 2010 on windows 7, so I have .net 4.0 programming.

I have created an ASP.NET project and made an .rdlc report and it displays the data great, but I would like the report to display a title similar to:

All values from [startDate] to [endDate] for [ID]. --Rest of Report in columns and rows--

From the .aspx web design page, the user enters the startDate and endDate into TextBox's: TextBox1 and TextBox2. Although the startDate and endDate is passed into a SQL command, it's not returned in the query as data to display.

Is there a way in the aspx.cs section of code (in C#) to change the values in the report itself using the TextBox1.Values.

Basically to set [startDate](from the .rdlc report) to TextBox1.Values from the .aspx ... etc.

Something like (even though I know this is isn't correct):

ReportViewer1.startDate = TextBox1.Value;

Thanks for the help if any.

Edit: I would post picks of what I am trying to do but I am new and reputation is to low it seems.

Basically in the .rdlc report I want to display in a TextBox.

Here are all the values for [Item] from the dates [startDate] to [endDate].

In a table in the report all the data is shown.

Example:

Here are all the values for TK421 from the dates 6/13/2014 to 2/3/2015.

Item | Value1 | Value2
TK421|  127   | 4

The web page is simply

Start Date  |  End Date  | Item
TextBox1    | TextBox2   | DropDownList1  | SearchButton

What I am simply trying to do is take the TextBox1 item from Start Date in the web page and put it in the [startDate] Field of the report. I have yet to find a good source of information on how to do this with some weird error.

Upvotes: 1

Views: 1522

Answers (1)

teo van kot
teo van kot

Reputation: 12491

It depends on how you use your ReportViewer component but if you use LocalReport property then you can onway set your parameters in .aspx codeBehind page like this:

YourReporViewer.LocalReport.SetParameters(new ReportParameter("startDate", TextBox1.Value));

You also can do it with ServerReport property.

For more detailed information you can read this.

Upvotes: 1

Related Questions