Search code examples
c#-3.0sql-server-2008-r2rdlcreport-viewer2010

RDLC ReportViewer control on a web page


I have a Report Viewer control on the home page of my reporting website. There are a series of custom filters on the page and a button. These are not a part of the report viewer toolbar. The report gets displayed the first time the page is loaded based on the filter criteria. Also, the user can change the filters and hit the 'Refresh' button to render the report. Is there a way by which I can stop the report to be displayed when the page is first loaded. I want the report to be displayed only when the user hits the 'Refresh' button. I don't want the report to hit the Sql Server database before the web page is loaded. I am using Visual Studio 2010 with Report Viewer 2010. Please help.

Thanks, SDD


Solution

  • Attack it from the data side.

    If your report is using a stored procedure, create a parameter so no data gets returned to the report on page load. Tie the parameter to a hidden field to turn it on after your user makes filter selections.

    here is a quick example of how you could retrun an empty data set for a user's report:

    CREATE PROCEDURE return_no_data_example

    @wantdata as bit = 0

    AS

    BEGIN

    if @wantdata = 0

    begin

    select * from gua..users where 1 = 2 
    

    end

    else

    begin

    select * from gua..users
    

    end

    END