dynamic-rdlc-generation https://www.e-learn.cn/tag/dynamic-rdlc-generation zh-hans How to set parameter values in RDLC https://www.e-learn.cn/topic/2809903 <span>How to set parameter values in RDLC</span> <span><span lang="" about="/user/167" typeof="schema:Person" property="schema:name" datatype="">半世苍凉</span></span> <span>2019-12-23 10:14:37</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have added two text boxes for the date range in the report. To fill the values in the text boxes, I set parameters to the text boxes.</p> <p>Now the date range is coming from a form named DateRange having two DateTimePickers. </p> <p>How to set the value of the text boxes in rdlc equal to these DataTimePickers?</p> <br /><h3>回答1:</h3><br /><p>You can set parameter value like this.</p> <pre><code>DateTime dtStartDate = dateTimePicker1.Value; DateTime dtEndDate = dateTimePicker2.Value; ReportParameter[] params = new ReportParameter[2]; params[0] = new ReportParameter("StartDate", dtStartDate, false); params[1] = new ReportParameter("EndDate", dtEndDate, false); this.ReportViewer1.ServerReport.SetParameters(params); </code></pre> <p>Passing Parameters to RDLC</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/27996831/how-to-set-parameter-values-in-rdlc</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/net" hreflang="zh-hans">.net</a></div> <div class="field--item"><a href="/tag/winforms" hreflang="zh-hans">winforms</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Mon, 23 Dec 2019 02:14:37 +0000 半世苍凉 2809903 at https://www.e-learn.cn What is the best way to dynamically generate RDLC report definitions at runtime? https://www.e-learn.cn/topic/2665182 <span>What is the best way to dynamically generate RDLC report definitions at runtime?</span> <span><span lang="" about="/user/159" typeof="schema:Person" property="schema:name" datatype="">余生颓废</span></span> <span>2019-12-20 04:13:46</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have data that will be generated by users at runtime by performing queries. The shape of the data is unknown because users can choose which fields to bring back.</p> <p>The application is an ASP.NET MVC web app. The data will be .NET POCOs. However, each object could have properties that are collections of other objects.</p> <p>I want to use the RDLC format for the reports so that I can leverage the PDF, Excel, Word, etc export functionality.</p> <p>I envisage the data being displayed in a grid, with nested grids for the collection properties.</p> <ol><li><strong>What are my options for generating the RDLC data?</strong></li> <li><strong>Can RDLC handle nested tables/grids for my collection properties requirement?</strong></li> </ol><br /><h3>回答1:</h3><br /><p>I investigated this theme a year ago, searching for an object model to generate RDLs in memory. There wasn’t one, but there are rumors about. A quick investigation nowadays: An object model called RDLOM exists, but isn’t really supported by Microsoft.</p> <p>My actual approach uses a self generated object model build upon RDLs scheme.</p> <p>This is a less-than-ideal solution, because you need to know the generated object in detail and because the object creation code is really ugly. But the other workarounds I found in my investigation use XML or XSLT directly to generate the RDL and they are poor in their own way. </p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/3437548/what-is-the-best-way-to-dynamically-generate-rdlc-report-definitions-at-runtime</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/net" hreflang="zh-hans">.net</a></div> <div class="field--item"><a href="/tag/reporting-services" hreflang="zh-hans">reporting-services</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/microsoft-reporting" hreflang="zh-hans">microsoft-reporting</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Thu, 19 Dec 2019 20:13:46 +0000 余生颓废 2665182 at https://www.e-learn.cn Dynamically binding of Dataset to RDLC Reports https://www.e-learn.cn/topic/2619344 <span>Dynamically binding of Dataset to RDLC Reports</span> <span><span lang="" about="/user/231" typeof="schema:Person" property="schema:name" datatype="">安稳与你</span></span> <span>2019-12-18 17:27:44</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I would like to bind the dynamically dataset to the rdlc. I can view the report if I use inline DataSource in ASPX file (static binding). However, if I use the following codes, the Report viewer keeps showing "Loading.." Image.</p> <p>I have already check the dataset name and if I changed the dataset name to "Orders2", it shows me that required dataset "Orders" is not provided. So, I add the GridView on the form and test my DataSet. The dataset contains data and showing well with the GridView.</p> <p>The problem is only with the Report and I could not bind data dynamically to the ReportViewer. Please help me. Thanks.</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { DataSet ds = GetDataSet(); ReportDataSource rds = new ReportDataSource("Orders", ds.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.Refresh(); GridView1.DataSource = ds; GridView1.DataBind(); } private DataSet GetDataSet() { var conString = ConfigurationManager.ConnectionStrings["dotnetConnectionString"]; string strConnString = conString.ConnectionString; SqlConnection conn = new SqlConnection(strConnString); conn.Open(); string sql = "Select * FROM Orders"; SqlDataAdapter ad = new SqlDataAdapter(sql, conn); DataSet ds = new DataSet(); ad.Fill(ds); return ds; } </code></pre> <p>ASPX codes are as below:</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt; &lt;rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="600px" Width="800px"&gt; &lt;LocalReport ReportPath="Reports\Report.rdlc"&gt; &lt;DataSources&gt; &lt;rsweb:ReportDataSource /&gt; &lt;/DataSources&gt; &lt;/LocalReport&gt; &lt;/rsweb:ReportViewer&gt; &lt;asp:GridView ID="GridView1" runat="server"&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <br /><h3>回答1:</h3><br /><p>I have already solved my problem.</p> <p>The problem is you need to add your codes under IsPostBack wrapping.</p> <pre><code>if (!Page.IsPostBack) { //your binding codes here } </code></pre> <br /><br /><br /><h3>回答2:</h3><br /><p>In the Pade_load event, add this code</p> <pre><code>ReportViewer1.LocalReport.ReportPath = Server.MapPath("\\Reports\\Report.rdlc"); this.ReportViewer1.Width = 800; this.ReportViewer1.Height = 600; </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/4652347/dynamically-binding-of-dataset-to-rdlc-reports</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/report" hreflang="zh-hans">report</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Wed, 18 Dec 2019 09:27:44 +0000 安稳与你 2619344 at https://www.e-learn.cn Base64 image doesn't display on Render PDF from RDLC report https://www.e-learn.cn/topic/2587426 <span>Base64 image doesn&#039;t display on Render PDF from RDLC report</span> <span><span lang="" about="/user/158" typeof="schema:Person" property="schema:name" datatype="">放肆的年华</span></span> <span>2019-12-18 05:43:42</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I'm trying to display image(base64 string) using parameter(<code>@CustomerSign</code>) in RDLC report <em>(I'm rendering PDF file from report and I'm seeing PDF file)</em></p> <p>I've configured image property as below:</p> <p>Select the image source : <code>Database</code> <br /> Use this field : </p> <pre><code>=Convert.FromBase64String(Parameters!CustomerSign.Value) </code></pre> <p>Use this MIME type: <code>image/png</code></p> <p>And passing parameter:</p> <pre><code>ReportParameter CustomerSign = new ReportParameter("CustomerSign", obj.SignImage); rptvw.LocalReport.SetParameters(CustomerSign); </code></pre> <p>But the image showing red Cross <code>[X]</code> instead of image, and doesn't gives an error! </p> <p>What could be the issue? </p> <p>I've also tried: How can I render a PNG image (as a memory stream) onto a .NET ReportViewer report surface</p> <br /><h3>回答1:</h3><br /><p>Support for images is pretty limited, this MSDN article discusses what you can do.</p> <p>Seems somewhat obvious from the question that embedding them in the report is not an option. But you <em>can</em> specify an external dbase as a source. Beware the EnableExternalImages property you have to set, as documented by the MSDN article. Seems the way to go, the question is not detailed enough, you might have to provide a suitable table with the desired image in your code.</p> <br /><br /><br /><h3>回答2:</h3><br /><p>First, check the Visual Studio output window. Any RDLC errors that you get should appear there when debugging.</p> <p>For example, I was getting an error saying that I was passing an invalid base64 string.</p> <p>If you see:</p> <blockquote> <p>Warning: The value of the ImageData property for the image ‘Image’ is “=Convert.From...”, which is not a valid ImageData. (rsInvalidDatabaseImageProperty)</p> </blockquote> <p>this seems to mean that an exception was thrown and so the expression did not evaluate and was passed as raw text (and so this message says that the raw text is not valid image data). The previous line in the output window should contain the actual error that caused the problem.</p> <p>In my case, following the pattern that you are using (thanks), my problem ended up being that my base64 in the database was prefixed with <code>data:image/png;base64,</code> since it was being pulled from and written to an html image element.</p> <p>To remove that prefix turned my RDLC expression to:</p> <pre><code>=Convert.FromBase64String(CStr(Parameters!Base64.Value).Substring(22)) </code></pre> <p>What I would suggest is pulling a base 64 string out of the database and confirm that it does actually work as an image. Try putting it into a base64 image viewer (for example: https://codebeautify.org/base64-to-image-converter). (Although in my case I guess that wouldn't have helped since that site still works even with that prefix.)</p> <br /><br /><br /><h3>回答3:</h3><br /><pre><code>=System.Convert.FromBase64String(Parameters!Logo.Value) </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/42020490/base64-image-doesnt-display-on-render-pdf-from-rdlc-report</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/image" hreflang="zh-hans">image</a></div> <div class="field--item"><a href="/tag/base64" hreflang="zh-hans">base64</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Tue, 17 Dec 2019 21:43:42 +0000 放肆的年华 2587426 at https://www.e-learn.cn How to page break after specific row(Suppose 25 rows) in rdlc reporting https://www.e-learn.cn/topic/2574675 <span>How to page break after specific row(Suppose 25 rows) in rdlc reporting</span> <span><span lang="" about="/user/65" typeof="schema:Person" property="schema:name" datatype="">血红的双手。</span></span> <span>2019-12-17 23:31:06</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>How to page break after Specific rows (like 15 rows) in rdlc reporting.</p> <br /><h3>回答1:</h3><br /><p>It's so easy.Suppose My reports looks like </p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/03701fda61dea77bbcf3c153c51a1bab.jpg" data-original="https://www.eimg.top/images/2020/03/22/03701fda61dea77bbcf3c153c51a1bab.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Enable advance mode</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/79a84759bc6ead9bc21d86251a6747c9.jpg" data-original="https://www.eimg.top/images/2020/03/22/79a84759bc6ead9bc21d86251a6747c9.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Add a group for page break</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/cd0a83ea59e8682df58480bb4cbd0e2e.jpg" data-original="https://www.eimg.top/images/2020/03/22/cd0a83ea59e8682df58480bb4cbd0e2e.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Define the number of rows what do you want in the group expression(In this case i want 15 rows) </p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/507bfa2a9e18e9f078c4d0449704ac61.jpg" data-original="https://www.eimg.top/images/2020/03/22/507bfa2a9e18e9f078c4d0449704ac61.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Delete group column if you not need</p> <p></p><p></p><img class="b-lazy" data-src="https://i0.wp.com/i.stack.imgur.com/vnJ8A.jpg" data-original="https://i0.wp.com/i.stack.imgur.com/vnJ8A.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p> <p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/191dd28c49ae7035f3a0c2ca3fa6ea35.jpg" data-original="https://www.eimg.top/images/2020/03/22/191dd28c49ae7035f3a0c2ca3fa6ea35.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Delete Expression from Group details </p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/664cb19557d78ac4ddd91c258ac2db5e.jpg" data-original="https://www.eimg.top/images/2020/03/22/664cb19557d78ac4ddd91c258ac2db5e.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/99978203986bfca9f2b65a448d23ffe7.jpg" data-original="https://www.eimg.top/images/2020/03/22/99978203986bfca9f2b65a448d23ffe7.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Select Group Properties and set page break attribute breakLocation as End,Disables as false and RestPageNumber as fasle.</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/a7186997cfdd3c0985acf1849dbd129e.jpg" data-original="https://www.eimg.top/images/2020/03/22/a7186997cfdd3c0985acf1849dbd129e.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Select Group Details Properties and Set Disable=true</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/3c46a98cc32cc3826925ff6241535f5e.jpg" data-original="https://www.eimg.top/images/2020/03/22/3c46a98cc32cc3826925ff6241535f5e.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>Now here's the report with page break after specific row</p> <p></p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/b87fb0d26740a8aa2b88252c8b3d7776.jpg" data-original="https://www.eimg.top/images/2020/03/22/b87fb0d26740a8aa2b88252c8b3d7776.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/22/d6a78eaf430de3f41a2dbfb6b4ef70f8.jpg" data-original="https://www.eimg.top/images/2020/03/22/d6a78eaf430de3f41a2dbfb6b4ef70f8.jpg" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p>If You want to keep Table Header in every page than click here</p> <br /><br /><br /><h3>回答2:</h3><br /><p>You can add Row Group to your Tablix. Then in row group properties select Page Break section and set "Between each instance of a group".</p> <br /><br /><br /><h3>回答3:</h3><br /><p>Maybe you can use a rectangle with pagebreak, the rectangle is able to define a fixed heigth</p> <br /><br /><br /><h3>回答4:</h3><br /><p>What I did was create another property on your object called lineBreak or something. when loading the objects make sure every 25 has the same number and increment by 1. then in table put a group over the details, grouping on lineBreak. then add an extra line inside that group, then every 25th row should be a blank line.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/10467997/how-to-page-break-after-specific-rowsuppose-25-rows-in-rdlc-reporting</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Tue, 17 Dec 2019 15:31:06 +0000 血红的双手。 2574675 at https://www.e-learn.cn Single RDLC file to populate any type of custom object passed to it https://www.e-learn.cn/topic/2493054 <span>Single RDLC file to populate any type of custom object passed to it</span> <span><span lang="" about="/user/190" typeof="schema:Person" property="schema:name" datatype="">邮差的信</span></span> <span>2019-12-13 23:28:27</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have a list of stored procedures which return different types of object (with varying column) to my business layer. Also, I created a single RDLC file named allreports.rdlc in my mvc application and put it in some .cshtml page.</p> <p>Now, I want to call any of the stored procedure (based on user input passed as query parameter to my controller) and retrieve data in dataset (or any better format if available) and want to pass it to my rdlc report.</p> <p>Can I achieve this using a single rdlc file which will be used to populate my any of the stored procedure dataset results. Also, please suggest if there is any other approach to achieve this?</p> <p>Goal: To integrate all the reports in a single report page by changing underlying data formats. I don't want to make my application releases for each new report requirement by changing the underlying codes.</p> <p>If any more clarification is needed; let me know instantly so that I could search the solution for it.</p> <br /><h3>回答1:</h3><br /><p>Syncfusion.EJ.ReportViewer library can dynamically create RDL reports in code behind by using ReportDefinition object. Please refer to sample that populates Tablix report item based on Datatable columns.</p> <p>Sample Link</p> <p></p> <p></p> <p>The whole product is available for free through the community license if you qualify (less than 1 million USD in revenue).</p> <p>I work for Syncfusion.</p> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/37447788/single-rdlc-file-to-populate-any-type-of-custom-object-passed-to-it</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/aspnet-mvc" hreflang="zh-hans">asp.net-mvc</a></div> <div class="field--item"><a href="/tag/dynamic-reports" hreflang="zh-hans">dynamic-reports</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Fri, 13 Dec 2019 15:28:27 +0000 邮差的信 2493054 at https://www.e-learn.cn How to use Run-Time Text Templates to do report grouping and sorting https://www.e-learn.cn/topic/2300612 <span>How to use Run-Time Text Templates to do report grouping and sorting</span> <span><span lang="" about="/user/112" typeof="schema:Person" property="schema:name" datatype="">回眸只為那壹抹淺笑</span></span> <span>2019-12-11 19:36:32</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I found this solution posted by reza-aghaei here </p> <p>It is really a helpful start to dynamic reporting, but I would like to extend it to grouping and sorting of the report.</p> <p>I have checked out the Microsoft documentation here but reporting is not discussed here.</p> <p>Any help with the grouping/sorting?</p> <p>来源:<code>https://stackoverflow.com/questions/58373578/how-to-use-run-time-text-templates-to-do-report-grouping-and-sorting</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-reports" hreflang="zh-hans">dynamic-reports</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Wed, 11 Dec 2019 11:36:32 +0000 回眸只為那壹抹淺笑 2300612 at https://www.e-learn.cn Pass parameter to rdlc from page with reportviewer https://www.e-learn.cn/topic/2287376 <span>Pass parameter to rdlc from page with reportviewer</span> <span><span lang="" about="/user/37" typeof="schema:Person" property="schema:name" datatype="">£可爱£侵袭症+</span></span> <span>2019-12-11 17:15:13</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have a visual studio 2013 web application which works with entity framework and I want to display a simple tabular data report using a RDLC report. </p> <p>I have created a seperate web page and added a reportviewer control. Also I have created a RDLC file and added the data source from a C# function which returns a <code>List</code> of custom objects. This way it is configurable from the report designer, but when the page loads in the browser an error <code>A data source instance has not been supplied for the data source 'DataSet1'</code> is shown.</p> <p><strong>Report design</strong> </p><p></p><p></p><img class="b-lazy" data-src="https://www.eimg.top/images/2020/03/21/49891bb6db59079df97580dceb9d813e.png" data-original="https://www.eimg.top/images/2020/03/21/49891bb6db59079df97580dceb9d813e.png" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><p></p><p></p> <p><strong>HTML markup</strong></p> <pre><code> &lt;rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"&gt; &lt;LocalReport ReportPath="Alumni\Reports\Report1.rdlc"&gt;&lt;/LocalReport&gt; &lt;/rsweb:ReportViewer&gt; </code></pre> <p>For above implementation I got the error of not giving a data source, but as Yuliam Chandra suggested, I added the below code and now the report works.</p> <pre><code> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", Business.ReportManager.GetMemberDetails(1))); } } </code></pre> <p>Please help me to solve this issue. I just need to display a simple report using RDLC and the data source is a public static function with an argument which returns a list of objects.</p> <br /><h3>回答1:</h3><br /><p>Have you set the data source in the page load? </p> <pre><code>YourReportViewer.LocalReport.DataSources.Add(new ReportDataSource("testDataSet", list)); </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/24969018/pass-parameter-to-rdlc-from-page-with-reportviewer</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/c" hreflang="zh-hans">c#</a></div> <div class="field--item"><a href="/tag/entity-framework" hreflang="zh-hans">entity-framework</a></div> <div class="field--item"><a href="/tag/reportviewer" hreflang="zh-hans">reportviewer</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Wed, 11 Dec 2019 09:15:13 +0000 £可爱£侵袭症+ 2287376 at https://www.e-learn.cn How to show a title on each page of the report dynamically created reportviewer https://www.e-learn.cn/topic/2137716 <span>How to show a title on each page of the report dynamically created reportviewer</span> <span><span lang="" about="/user/40" typeof="schema:Person" property="schema:name" datatype="">こ雲淡風輕ζ</span></span> <span>2019-12-10 18:52:35</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I create the report dynamically, i e, I have no way to open a designer RDLC and fix it. I create a table and fill it through the dataset. Getting XML file and export it to PDF file. But even if I write</p> <pre><code>string deviceInfo = "&lt;DeviceInfo&gt;" + " &lt;OutputFormat&gt;PDF&lt;/OutputFormat&gt;" + " &lt;PageWidth&gt;11in&lt;/PageWidth&gt;" + " &lt;PageHeight&gt;8.5.0in&lt;/PageHeight&gt;" + " &lt;MarginTop&gt;0.05in&lt;/MarginTop&gt;" + " &lt;MarginLeft&gt;0.05in&lt;/MarginLeft&gt;" + " &lt;MarginRight&gt;0.05in&lt;/MarginRight&gt;" + " &lt;MarginBottom&gt;0.05in&lt;/MarginBottom&gt;" + " &lt;KeepWithGroup&gt;After&lt;/KeepWithGroup&gt;" + " &lt;RepeatOnNewPage&gt;true&lt;/RepeatOnNewPage&gt;" + " &lt;FixedData&gt;true&lt;/FixedData&gt;"+ " &lt;RepeatHeaderOnNewPage&gt;true&lt;/RepeatHeaderOnNewPage&gt;" + "&lt;/DeviceInfo&gt;"; try { byte[] bytes = reportViewer1.LocalReport.Render( "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); fs.Close(); } return filename; } //.... </code></pre> <p>I see the title only on 1 page Help solve the problem! Thanks!</p> <br /><h3>回答1:</h3><br /><pre><code> private Rdl.HeaderType CreateHeader() { Rdl.HeaderType header = new Rdl.HeaderType(); header.Items = new object[] { CreateHeaderTableRows(), true, }; header.ItemsElementName = new Rdl.ItemsChoiceType20[] { Rdl.ItemsChoiceType20.TableRows, Rdl.ItemsChoiceType20.RepeatOnNewPage, }; return header; } //.... public string ExportReport(string filename) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; string deviceInfo = "&lt;DeviceInfo&gt;" + " &lt;OutputFormat&gt;PDF&lt;/OutputFormat&gt;" + " &lt;PageWidth&gt;11in&lt;/PageWidth&gt;" + " &lt;PageHeight&gt;8.5.0in&lt;/PageHeight&gt;" + " &lt;MarginTop&gt;0.05in&lt;/MarginTop&gt;" + " &lt;MarginLeft&gt;0.05in&lt;/MarginLeft&gt;" + " &lt;MarginRight&gt;0.05in&lt;/MarginRight&gt;" + " &lt;MarginBottom&gt;0.05in&lt;/MarginBottom&gt;" + "&lt;/DeviceInfo&gt;"; try { byte[] bytes = reportViewer1.LocalReport.Render( "PDF", deviceInfo, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); fs.Close(); } return filename; } catch (Exception e) { Program.WriteLogEx.WriterLogErr(e.Message); return ""; } } </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/10869315/how-to-show-a-title-on-each-page-of-the-report-dynamically-created-reportviewer</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/xml" hreflang="zh-hans">xml</a></div> <div class="field--item"><a href="/tag/reportviewer" hreflang="zh-hans">reportviewer</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Tue, 10 Dec 2019 10:52:35 +0000 こ雲淡風輕ζ 2137716 at https://www.e-learn.cn Data not Loaded in reportviewer VB.NET https://www.e-learn.cn/topic/1850990 <span>Data not Loaded in reportviewer VB.NET</span> <span><span lang="" about="/user/36" typeof="schema:Person" property="schema:name" datatype="">ぃ、小莉子</span></span> <span>2019-12-06 14:38:05</span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><h3>问题</h3><br /><p>I have created the stored procedure in ms-sql server 2014 and creating the rdlc report. Now binding the report in reportviewer programatically, but in report only columns are displayed and not the data...</p> <p>The below code is my stored procedure :</p> <pre><code>USE [Bonny] GO /****** Object: StoredProcedure [dbo].[AccMast_AllDetail] Script Date: 17/10/2016 12:10:42 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER Proc [dbo].[AccMast_AllDetail] as Select Account_Code,Party_Name,Address_1,Address_2,City from FAMPAR order by Account_Code GO </code></pre> <p>My VB.NET code in reportviewer form load event...</p> <pre><code> ReportViewer.Reset() Dim data As New AccMastDataSet Dim ReportDataSource1 As ReportDataSource = New ReportDataSource ReportDataSource1.Name = "AccMastDataSet" ReportDataSource1.Value = rds ReportViewer.LocalReport.DataSources.Clear() ReportViewer.LocalReport.DataSources.Add(ReportDataSource1) ReportViewer.LocalReport.ReportEmbeddedResource = "Report1.rdlc" ReportViewer.LocalReport.ReportPath = "D:\netbonny\netbonnyproject\netbonnyproject\Reports\Report1.rdlc" ReportViewer.RefreshReport() </code></pre> <p>In this I am getting column headers but not the Data, data is there and checked in sql management studio...</p> <p>Another VB.NET code I tried is :</p> <pre><code>Dim data As New AccMastDataSet Dim abc = data.Tables("AccMast_AllDetail") Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("AccMastDataSet", data) ReportViewer.LocalReport.DataSources.Clear() ReportViewer.LocalReport.DataSources.Add(rds) ReportViewer.LocalReport.ReportEmbeddedResource = "netbonnyproject.Report1.rdlc" ReportViewer.RefreshReport() </code></pre> <p>Here I am getting error : </p> <p></p> <p>I have no Idea what it says...</p> <p>Help me out in here.</p> <br /><h3>回答1:</h3><br /><p>Currently you have passed a <code>DataTable</code> of a new instance of a <code>DataSet</code> to report data source. So obviously it should be empty and you will see report column headers without any data.</p> <p>You should load data into the <code>DataTable</code> and then pass it to report. </p> <p>For example, if you dropped a <code>TableAdapter</code> on your form, you can use such code:</p> <pre><code>Me.Table1TableAdapter.Fill(Me.DataSet1.Table1) Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", Me.DataSet1.Table1) </code></pre> <p>Also</p> <pre><code>Dim cn = "Connection String" Dim cmd = "Stored Procedre Name" Dim table = New DataTable() Using adapter As New SqlDataAdapter(cmd, cn) adapter.SelectCommand.CommandType = CommandType.StoredProcedure adapter.Fill(table) End Using Dim rds = New Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", table) </code></pre> <br /><br /><p>来源:<code>https://stackoverflow.com/questions/40081287/data-not-loaded-in-reportviewer-vb-net</code></p></div> <div class="field field--name-field-tags field--type-entity-reference field--label-above"> <div class="field--label">标签</div> <div class="field--items"> <div class="field--item"><a href="/tag/sql-server" hreflang="zh-hans">sql-server</a></div> <div class="field--item"><a href="/tag/vbnet" hreflang="zh-hans">vb.net</a></div> <div class="field--item"><a href="/tag/winforms" hreflang="zh-hans">winforms</a></div> <div class="field--item"><a href="/tag/rdlc" hreflang="zh-hans">rdlc</a></div> <div class="field--item"><a href="/tag/dynamic-rdlc-generation" hreflang="zh-hans">dynamic-rdlc-generation</a></div> </div> </div> Fri, 06 Dec 2019 06:38:05 +0000 ぃ、小莉子 1850990 at https://www.e-learn.cn