2014-06-10 37 views
0

mvc4 project我們使用.rdlc reportsI need to show textbox to take parameter on .rdlc reports on report name filter.需要設置參數在MVC項目動態RDLC報告

My problem is want to show those textboxes on report file like ssrs reports does (.rdl files)

,我不希望創建不同組的partial views (.cshtml) files.

與例如任何線程將有幫助。

我沒有谷歌,但沒有運氣。

回答

1

ReportViewer控件是一個服務器端控件,並且需要ViewState,.cshtml文件不能這樣工作。

我會盡量說明我的方式做到了:

  • 控制器/報告

    • ReportController

      • 的ActionResult指數()
        • //顯示視圖
      • FileResult Get(string p1,string p2 ...)//您想要的任何參數。

        // Start a ReportViewer control, set the source (rdcl file), 
        // Set the parameters based on (p1, p2, etc), 
        // Use ReportViewercontrol.LocalReport.Render, specify "PDF". 
        // Use the byte[] result to return a new File() 
        
  • 查看/
    • 報告
      • 指數 //將您的參數輸入。 //從javascript中調用ReportController/Get,將結果呈現在div中刷新。
+0

我試圖以同樣的方式,但需要顯示參數'textbox'動態我該怎麼辦呢?我很困惑 – Neo

+0

你的文本框可以是一個HTML常規輸入框。 要做到「dinamically」這意味着去服務器和創建一個新的報告,你可以使用jQuery.ajax功能。讓我找到一個例子並更新答案。 – celerno

+0

@ashish檢查一個示例,http://jsfiddle.net/k9jbR/。這將是你的index.cshtml,你需要設置控制器的權利。此外,您可能需要設置特定的響應類型才能強制顯示PDF而不是下載PDF。對不起,現在做不了多少。 – celerno