locked
report viewer RRS feed

  • Question

  • User-265772647 posted

     In my application want to display report depening upon empname . if user enter  empname in textbox and click on reprtsbtn it should show report for that empname.But i dont know how to send parameters  empname  and clientid  to generate report.

    below sql query in dataset reports.xsd

    
    
    select distinct EmpID,EmpName,SDate,EDate,Total from Employee where EmpName=@EmpName and ClientID=@ClientID


    Reports.aspx

    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
                    Font-Size="8pt" Height="400px" Width="837px">
                    <LocalReport ReportPath="Reports.rdlc">
                        <DataSources>
                            <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" 
                                Name="AReport_EmpAsReport" />
                        </DataSources>
                    </LocalReport>
                </rsweb:ReportViewer>
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                    SelectMethod="GetData" 
                    TypeName="AReportTableAdapters.EmpAsReportTableAdapter">
                </asp:ObjectDataSource>
            

    list.aspx

    empname :textbox

    protected void btnreports_Click(object sender, EventArgs e) { Response.Redirect("Reports.aspx"); }

    when i ckick on generatetn it shows below error

    An error has occurred during report processing.
     ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'GetData' that has no parameters.
     



    Monday, June 2, 2014 1:15 PM

Answers

  • User-734925760 posted

    my application  ClientID .emptextbox ,generatebutton in list.aspx .reportviewer in reports.aspx

    According to your description, you will enter text and click the generate button in list.aspx, then you will get the text which is entered in list.aspx and generate the report in reports.aspx. So far as I know, as we click the generate button, we can pass the text to reports.aspx using response.Redirect() function, in the reports.aspx, you will set the value as parameter.

    For more information about pass parameter, please refer to the code below:

    Response.Redirect("reports.aspx?id=123");

    Get the pass value use the code below:

    string id = Request.QueryString["id"];

    For more information about set parameter in report viewer, please refer to the link below:

    http://www.codeproject.com/Questions/614784/How-to-pass-paramenters-from-ReportViewer-control

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 3, 2014 3:47 AM

All replies

  • User2103319870 posted

    You can use the SelectParameters property in objectdatasource to pass the parameters to report.

    Please try with the below code

    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetData"
            TypeName="AReportTableAdapters.EmpAsReportTableAdapter">
            <SelectParameters>
                <asp:ControlParameter ControlID="txtEmpName" Name="EmpName" PropertyName="Text"
                    Type="String" DefaultValue="Your Default EmpName Value" />
                    <asp:ControlParameter ControlID="txtClientID" Name="ClientID" PropertyName="Text"
                    Type="String" DefaultValue="Your Default ClientID Value" />
            </SelectParameters>
        </asp:ObjectDataSource>

    Monday, June 2, 2014 1:44 PM
  • User-265772647 posted
    	

    thanku .Its working if controls and reportviewer is in single aspx page. .

    In my application  ClientID .emptextbox ,generatebutton in list.aspx .reportviewer in reports.aspx.Above  procedure works when  all controls and reportviewer in list.aspx It is working .If reportviewer is in reports.aspx how to get these list .aspx  controls ControlID's .I was trying  but ididn't get anything.

    Monday, June 2, 2014 2:31 PM
  • User-734925760 posted

    my application  ClientID .emptextbox ,generatebutton in list.aspx .reportviewer in reports.aspx

    According to your description, you will enter text and click the generate button in list.aspx, then you will get the text which is entered in list.aspx and generate the report in reports.aspx. So far as I know, as we click the generate button, we can pass the text to reports.aspx using response.Redirect() function, in the reports.aspx, you will set the value as parameter.

    For more information about pass parameter, please refer to the code below:

    Response.Redirect("reports.aspx?id=123");

    Get the pass value use the code below:

    string id = Request.QueryString["id"];

    For more information about set parameter in report viewer, please refer to the link below:

    http://www.codeproject.com/Questions/614784/How-to-pass-paramenters-from-ReportViewer-control

    Hope it's useful for you.

    Best Regards,

    Michelle Ge

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 3, 2014 3:47 AM