Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Announcements
Vendor Announcements
How to display barcodes in the Page Header and Footer of a Report (RDL or RDLC)
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Neodynamic, post: 106654, member: 5006"] [b]Technologies used[/b] - Neodynamic Barcode Professional 3.0 for Reporting Services - Microsoft .NET Framework 1.1 or greater - Microsoft Visual Studio .NET 2003, Microsoft Visual Studio 2005 or SQL Server Business Intelligence Development Studio - Microsoft SQL Server 2000/2005 Reporting Services or Visual Studio Local Reports RDLC A common need or requirement in barcode reporting scenarios is to display barcodes in the Page Header or/and Footer of a Report. [img]http://www.neodynamic.com/Support/FAQs/60/figure00.png[/img] A SQL Server Reporting Services 2000/2005 Report (RDL file) or a Visual Studio Local Report (RDLC file) can contain a header and footer that run along the top and bottom of each page, respectively. The important thing to keep in mind regarding headers and footers is that they can contain static text, images, lines, rectangles, borders, background color, and background images ONLY, i.e. you cannot add databound fields or images directly to a header or footer and given that, it becomes in a problem when working with barcodes in such page sections because in most cases you'll want to encode a databound field. The following guide tries to provide you with a solution to this "limitation". In the following guide we're going to create a Report Server Project which shows barcode images into a Page Header section of a simple report. This guide was developed by using Barcode Professional, Visual Studio 2005 and Reporting Services 2005. However, the same method stated here is valid for Reporting Services 2000 projects and Visual Studio Local Reports RDLC! The idea is very simple... create a Product Catalog for AdventureWorks (A fictitious company which database is delivered with SQL Server 2005). [b]Follow these steps[/b] - Open [b]Visual Studio 2005[/b] or [b]SQL Server Business Intelligence Development Studio[/b] and create a new [b]Report Server Project[/b] - Add a new [b]Shared Data Source[/b] pointing to the [b]AventureWorks[/b] database sample - Add a new [b]blank Report[/b] and open it at design-time. Click on [b]Data[/b] tab, select [b]New DataSet[/b] from the drop down list and write the following SQL Statement in the [b]Query String[/b] textbox: SELECT Production.vProductModelCatalogDescription.ProductModelID, Production.vProductModelCatalogDescription.Summary, Production.vProductModelCatalogDescription.Name, Production.vProductModelCatalogDescription.WarrantyPeriod, Production.vProductModelCatalogDescription.Wheel, Production.vProductModelCatalogDescription.Saddle, Production.vProductModelCatalogDescription.Pedal, Production.vProductModelCatalogDescription.BikeFrame, Production.vProductModelCatalogDescription.Crankset, Production.vProductModelCatalogDescription.Color, Production.vProductModelCatalogDescription.Material, Production.ProductPhoto.LargePhoto FROM Production.vProductModelCatalogDescription INNER JOIN Production.ProductPhoto ON Production.vProductModelCatalogDescription.ProductPhotoID = Production.ProductPhoto.ProductPhotoID WHERE (Production.vProductModelCatalogDescription.ProductModelID = @ModelID) [img]http://www.neodynamic.com/Support/FAQs/60/figure01_small.png[/img] The DataSet1 settings for the report Click [b]OK[/b] to save the DataSet. After that, [b]add a new DataSet[/b] by selecting [b]<New DataSet...>[/b] from the [b]DataSet drop down list[/b] on the [b]Data tab[/b]. Write the following SQL Statement in the Query String textbox: SELECT ProductModelID, Name FROM Production.vProductModelCatalogDescription ORDER BY Name [img]http://www.neodynamic.com/Support/FAQs/60/figure01b_small.png[/img] The DataSet2 settings for the report Click [b]OK[/b] to save the DataSet. - Go back to the [b]Layout[/b] tab. It´s time to display the Report Page´s Header and/or Footer on the report designer. To do that just go to [b]Report menu[/b] and click on [b]Page Header and/or Page Footer[/b] depending on where you want to display the barcode image. In this case, we´ll select [b]Page Header[/b] only. [img]http://www.neodynamic.com/Support/FAQs/60/figure02_small.png[/img] Display the Page Header and/or Page Footer on the Report Designer After that, the Page Header and/or Page Footer should be displayed by the Report Designer so you can place the allowed objects onto it. - Barcode Professional settings for the barcode generation: + Install Barcode Professional for Reporting Services on your machine so it can be used with it. [b]IMPORTANT:[/b] If you are using Visual Studio Local Reports RDLC, then after installing Barcode Professional for Reporting Services you must register it into the Global Assembly Cache (GAC). The assembly to register is located in [BarcodeInstallDir]\bin\For SSRS 2005\Neodynamic.ReportingServices.Barcode.dll + Add a reference to the [b]Barcode Professional assembly[/b] ([b]Neodynamic.ReportingServices.Barcode.dll[/b]) going to [b]Report > Report Properties[/b]. In the dialog box shown, click on [b]References[/b] tab and add a reference to the Barcode assembly as is shown in the following figure: [img]http://www.neodynamic.com/Support/FAQs/60/figure03_small.png[/img] Adding a reference to Barcode Professional assembly Click on [b]Add[/b] button and then on [b]OK[/b] button. After that, we'll need to [b]create an instance of Barcode Professional to use it then in a custom function[/b]. To do this, add a new entry in the [b]Classes[/b] grid as is shown in the following figure. Note that the instance will be called [b]objBarcode[/b] and that the full reference to the class is [b]Neodynamic.ReportingServices.Barcode[/b] [img]http://www.neodynamic.com/Support/FAQs/60/figure04_small.png[/img] Creating an instance of Barcode Professional + Then click on [b]Code[/b] tab and write the following function that utilizes the barcode instance created above to generate the desired barcode image. [b]NOTE:[/b] In this case we opt for using [b]Code 128 Symbology[/b] to encode the [b]Product Model ID[/b] which will be passed to this function through the [b]valueToEncode parameter[/b]. [img]http://www.neodynamic.com/Support/FAQs/60/figure05_small.png[/img] The VB.NET Function that will generate the barcode image Public Function GetBarcode(ByVal valueToEncode As String) As Byte() objBarcode.Code = valueToEncode objBarcode.Symbology = Neodynamic.ReportingServices.Symbology.Code128 objBarcode.BarWidth = 0.01 objBarcode.BarHeight = 0.4 objBarcode.AutoSize = False objBarcode.Width = 2.875 objBarcode.Height = 0.625 Return objBarcode.GetBarcodeImage() End Function Notice that in the function above, we set the [b]AutoSize[/b] property of Barcode Professional to [b]False allowing us to CENTER the barcode image inside the dimensions specified in the Width and Height properties (which are measured in inches[/b]). You´ll see this effect after you run your report later. - [b]Report Layout[/b] In our sample the report will allow us to select a [b]Product Name[/b] in order to display information about the selected product in the form of [b]DataSheet[/b]. The Product DataSheet will feature a [b]barcode[/b] image in the [b]Page Header[/b] section encoding the string "[b]Model ID: [/b]" + [b]the ProductModelID data field[/b]. + Go to [b]Report menu[/b] and click on [b]Report Parameters...[/b] and modify the existing parameter called [b]ModelID[/b] (which was automatically created by the report designer based on the DataSet1 SQL statement) with the data shown in the following figure: [img]http://www.neodynamic.com/Support/FAQs/60/figure06_small.png[/img] The Report Parameter settings for the Product Model ID Click [b]OK[/b] to save the changes. + Now it´s time to design the report for the Product DataSheet. Design the report as is shown in the following figure. [img]http://www.neodynamic.com/Support/FAQs/60/figure07_small.png[/img] The Product DataSheet report layout [b]Report Layout Description[/b] [b]1- Header Section[/b] It contains [b]2 Rectangles[/b]. The first one on the just contains [b]2 TextBox[/b] with static text. The most important is the rectangle on the right which contains: - A [b]TextBox[/b] to display the selected Product Name and which [b]Value[/b] property is set to =[b]Parameters!ModelID.Label[/b] - An [b]Image[/b] control that will display the barcode generated by the function we wrote in the [b]Code[/b] section (See the setting in the [b]Value[/b] property below). The properties of the [b]Image[/b] control to set up are the following: -- [b]MIMEType[/b] is set to [b]image/bmp[/b] -- [b]Source[/b] is set to [b]Database[/b] -- [b]Value[/b] is set to =[b]Code.GetBarcode("Model ID: " & ReportItems!txtProductModelID.Value)[/b] -- [b]Sizing[/b] is set to [b]AutoSize[/b] -- [b]Size Width[/b] is set to [b]2.875in[/b] (the same value that appears in the GetBarcode function) -- [b]Size Height[/b] is set to [b]0.625in[/b] (the same value that appears in the GetBarcode function) [b]2- Body Section[/b] It contains a [b]List[/b] control with the following property settings: - [b]DataSetName[/b] is set to [b]DataSet1[/b] - The [b]List[/b] control also contains [b]2 Rectangles.[/b] [b]3-[/b] A [b]Rectangle[/b] which contains [b]an Image[/b] and [b]3 TextBox:[/b] - An [b]Image[/b] control to display the product photo. The properties of the [b]Image[/b] control to set up are the following: -- [b]MIMEType[/b] is set to [b]image/bmp[/b] -- [b]Source[/b] is set to [b]Database[/b] -- [b]Value[/b] is set to =[b]Fields!LargePhoto.Value[/b] -- [b]Sizing[/b] is set to [b]AutoSize[/b] - A [b]TextBox[/b] to display the Product Summary and which [b]Value[/b] property is set to =[b]Fields!Summary.Value[/b] - A [b]TextBox[/b] to display the Warranty period of the Product and which [b]Value[/b] property is set to =[b]Fields!WarrantyPeriod.Value + " Warranty!"[/b] - A [b]TextBox[/b] to display the Warranty period of the Product and which: -- [b]Value[/b] property is set to =[b]Fields!ProductModelID.Value[/b] -- [b]Visibility > Hidden[/b] property is set to [b]True[/b] (We do not want to display this field because it will be encoded in the barcode in the Page Header!) [b]4[/b] A [b]Rectangle[/b] which contains a set of [b]TextBox[/b] for the rest of the data fields. Please refer to the figure above in order to see how to set up the [b]Value[/b] properties of each [b]TextBox[/b] - That´s it. If you run the report you'll see the barcode image for the Product Model ID field in the Page Header after you select a Product from the drop down list. [img]http://www.neodynamic.com/Support/FAQs/60/figure09_small.png[/img] The barcode image in the Page Header section - Deployment Please refer to the product help documentation about this topic. [b]Links:[/b] [url=http://www.neodynamic.com/ND/FaqsTipsTricks.aspx?tabid=66&prodid=7&sid=60]This Demo[/url] [url=http://www.neodynamic.com/Products/Demos/Demos.aspx?tabid=81&prodid=7]More Demos[/url] [url=http://www.neodynamic.com/ND/Downloads.aspx?tabid=79&prodid=7]Download Barcode Professional for Reporting Services[/url] [url=http://www.neodynamic.com/Products/BCRS/BarcodeRS.aspx?tabid=78&prodid=7]More Information about Neodynamic Barcode Professional for Reporting Services[/url] Neodynamic .NET Components & Controls [url=http://www.neodynamic.com]Neodynamic[/url] [url=http://www.barcode-for-reporting-services.com]Neodynamic Barcode Professional for Reporting Services[/url] [/QUOTE]
Insert quotes…
Verification
Post reply
Announcements
Vendor Announcements
How to display barcodes in the Page Header and Footer of a Report (RDL or RDLC)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom