?
Solved

ReportViewer arguments

Posted on 2010-09-22
2
Medium Priority
?
356 Views
Last Modified: 2013-12-16
I have a ReportViewer on a page, but I need to be able to set variables such as StartDate and EndDate inside the query for the report, but can seem to find any examples of how to set a query in code.

The field names will remain the same, so hopefully I dont need to re-design the report, all I really need to do is something like ReportViewer1.query = "select * from myTable where startDate < = 22/09/2010"

Any suggestions or examples would be great if anyones done anything like this before?

Thank you in advance!

Tony Cross
0
Comment
Question by:tonelm54
2 Comments
 
LVL 7

Expert Comment

by:DanSo1
ID: 33742393
I think it's good time for you, to choose some leading solution for reporting.
I was using many of different reporting tools but for me the best so far is FastReport.
If you can't switch, please send us more code - then somebody will help you quicker.

Regards
  Daniel

0
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 33745047
If you are setting the datasource in a ASP.NET web page, then just use a SelectParameter.  In the example below, I'm using a QueryStringParameter.  
<rsweb:ReportViewer ID="ReportViewer1" runat="server" ExportContentDisposition="AlwaysInline">
            <LocalReport EnableExternalImages="True" ReportPath="Design.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1_tblContracts" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}"
            SelectMethod="GetData" TypeName="DataSet1TableAdapters.tblContractsTableAdapter">
            <SelectParameters>
                <asp:QueryStringParameter Name="contactID" QueryStringField="id" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource> 

Open in new window

0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question