0

I am new to report viwer, I wanted to know that how to pass the select parameter to report viewer and also to data source? I need to pass the start date and end date to the data source for filtering data and also show in report viewer. Anyone suggest?

>     <rsweb:ReportViewer ID="Log_ReportViewer" runat="server" Height="545px" Width="962px" Font-Names="Verdana" Font-Size="8pt"
> WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
>         <LocalReport ReportPath="Reporting\ReportRDLC File\LogReport.rdlc">
>             <DataSources>
>                 <rsweb:ReportDataSource DataSourceId="SqlDataSource1" Name="Log" />
>             </DataSources> 
>         </LocalReport>
>     </rsweb:ReportViewer>
>     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:InvControlConnectionString %>"
> ProviderName="<%$
> ConnectionStrings:InvControlConnectionString.ProviderName %>"
> SelectCommand="SELECT * FROM logs WHERE log_createDate >= startDate AND log_createDate >= endDate">
>         <SelectParameters>
>             <asp:QueryStringParameter Name="endDate" QueryStringField="endDate" />
>             <asp:QueryStringParameter Name="startDate" QueryStringField="startDate" />
>         </SelectParameters>
>     </asp:SqlDataSource> </asp:Content>

1 Answer 1

1

Through the code behind, like that:

ReportParameter[] parameters = new ReportParameter[yournumberofparamaters];
parameters[0] = new ReportParameter("name", value);
parameters[1] = new ReportParameter("name", value);
parameters[2] = new ReportParameter("name", value);
this.Log_ReportViewer.LocalReport.SetParameters(parameters);
Sign up to request clarification or add additional context in comments.

7 Comments

Hi i try this code before but it show me LocalProcessingException at the last line of code.
@FirionRedfield Share the exception message please.
An exception of type 'Microsoft.Reporting.WebForms.LocalProcessingException' occurred in Microsoft.ReportViewer.WebForms.dll but was not handled in user code
This isn't the exception message.
I got only got this message
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.