Pagination in a rdlc report - c#

How can I set the pagination or the number of items being displayed in a single page? Suppose there are 1000 items and at each page I want to show 100 and use a next button to navigate to the next page . How can I be able to do that, Please discuss it in c# context .
Thank You.

You can do this by using PageBreaks.
From MSDN:
Page Breaks
In some reports, you may want to place
a page break at the end of a specified
number of rows instead of, or in
addition to, on groups or report
items. To do this, create a group in a
data region (typically a group
immediately outside the detail), add a
page break to the group, and then add
a group expression to group by a
specified number of rows.
The following expression, when placed
in the group expression, assigns a
number to each set of 25 rows. When a
page break is defined for the group,
this results in a page break every 25
rows.
=Int((RowNumber(Nothing)-1)/25)
Taken from http://msdn.microsoft.com/en-us/library/ms251668(VS.80).aspx

Related

Printing nested loops using C# PrintDocument and the PrintPage event

I am writing a C# WinForms app, and part of it includes generating inventory reports. I can't print the inventory one item per line, because each inventory item may be located in more than one location. So, the goal is to print the name of the product (and a few other details) one one line, and below it, print a list of locations where the item is located and how many should be in each location, basically like this:
WIDGET (ACME, INC) PRODUCT #123435 TOTAL ON HAND: 30
Aisle: 10 Count: 15
Aisle: 4 Count: 6
Aisle: 15 Count: 9
SNIPE (ACE SNIPE CO) PRODUCT #67890 TOTAL ON HAND: 11
Aisle: 1 Count: 4
Aisle: 3 Count: 7
and so on...
The problem I'm running into is, to print this requires a loop within a loop - the outer loop is the list of products, and the inner loop is the list of locations and counts for each product. What I can't figure out is how to cause a page break when I am inside the inner loop and hit the bottom of the page. What needs to happen is for the printing routine to print a new page header but then pick up where it left off in the list of locations for the product it was printing.
The printing code I've written works well except I can't figure out how to catch hitting the bottom of the page to start a new page while inside the inner loop[, so the printing runs off the bottom of the page.
So the question is, when you have a loop inside another loop while printing, how do you check page position and start a new page that continues where you left off? I'd be glad to provide the code I have for this so far, but I thought the explanation of the problem might be easier for people to understand and provide some guidance on. I have been banging my head against the wall on this for a couple days, and nothing I've found anywhere on the web addresses this.
Thanks for any help that is given.
The focus is on the PrintPage event, which has a HasMorePages property. If this property is true, he will open a new page and execute the custom event bound to PrintPage again. So it is equivalent to a recursion, you need to return this method at the right time. Finally, set HasMorePages to false so it won't recycle.

How to load two RDLC reports in same report viewer?

I have two reports the first one to show general information and the second one to show details and I need to show each one in a different page in report viewer
can you help me to do that
thanks
like the image
Hopefully, the following can help guide you into what you are looking for. First, you will need THREE reports and TWO datatables (or other lists as you have to build your report).
First, On the 3 reports I describe, I would not worry about any of the report final formatting to be perfectly aligned, bold, spacing... get it to work, then you can make it pretty after all is functional.
Next, create a bogus datatable "MyTable" for the sole purpose of creating two records. Even if a single column of "MyGroup" and having it as an int (just for sample purposes).
Now, create two records and set the values in each row to 1 and 2 respectively so your table has
MyGroup
1
2
Now, for the other two reports. It is my understanding that you want the first report to show a summary of each department's totals with a grand-total. The second report is showing the details of all the activity per department. So this is basically using the same dataset returned from whatever query. For this example, I will refer to the datatable as "SalesData".
CREATING THE REPORTS
Create your first report, put a table control on the report, full width you will have for your current reports as landscape or portrait as long as both the same size, you want this report to be the same. Ex: ALL will be portrait. Add your Report Data source to show the "MyTable" and assign that to the table control. Also add the "SalesData" table to the report as well so it is available to the future sub-reports.
On the table control, below where it shows the "Row Groups", add a "Group By" for the "MyGroup" column. This is so we can force a page-break between each group. Once added, right-click on the parent group "MyGroup" and select "Group Properties". This will show an option on the left side to allow you to set page breaks, click the checkbox for "Between each instance of a group". For now, just have the one column in the table control as the "MyGroup" column. Save the report ex: "MySalesRpt.rdlc". Then compile and run the report. You should get this simple report with 2 pages, each showing just the number 1 and 2 respectively. NOTE: You will also want to add the datatable reference for your secondary reports to this main report as well so they are available as sub-reports of the first.
Create a new report ex: "MySalesDetail.rdlc", add the "SalesData" to it. Add a table control to the report and set its source to the "SalesData" table. Include whatever for your detail columns you want to show of the sales activity. Add a data group based on the department, get your sum( salesDollarColumn ). Add a new row outside/below the group footer so you can have the report grand totals as a sum of all ex: SalesDollarColumn. You can test and run this report on its own until it looks correct.
Now, your third report. Copy/paste the MySalesDetail.rdlc report and change it to MySalesSummary.rdlc. So you don't this summary report showing every row that builds the grand total sum() per each department, right-click on the row that represents the details of the group and delete. It will ask if you want to delete rows and associated groups? Reply yes as it will just remove the details row, but keep the group footer that will retain your sum() total per department. Save, test / run this report.
Once all 3 reports work individually, now we can go back to the "MySalesRpt". Add an additional DETAIL row in this otherwise simple 1-detail report. Right-click on the existing detail row and then pick "Insert Row" -> "Inside Group - Below". This will now show as two rows.
Now, in the first row of the report where it did have just a simple textbox, go to your report Toolbox and pick Subreport and put one instance into each row.
On the first row, subreport, right-click and set properties. Set both the Name and "Use this report as a subreport" to the summary report "MySalesSummary". On the second row subreport, do the same but with "MySalesDetail".
Final step. Click on the Subreport representing the "MySalesSummary". Go to the properties of that and scroll down to the "Hidden" property. You want to have this value set to the expression: ex: "=Fields!MyGroup.Value = 2". This way the report will ONLY be generate when it is on the first record where MyGroup = 1.
Similarly, on the second subreport representing the detail, set the hidden equal to the opposite.. "=Fields!MyGroup.Value = 1". Hide when the MyGroup = 1. This way you can have each report on their own page, but only one will show up per group.
I know is sounds deep, but do it slowly and it should work for you. I already did and confirmed this process works. Sorry so many steps, but it has to be broken into multiple parts to tie them all together as you are requesting.
One rdlc in main local report and the other in subreport. Then set InteractiveSize in the main local report to break it to show each one in a different page in report viewer.

Using Word Interop, how does one tell if a table is going to span multiple pages?

Is there any way to catch a break in the table in order to insert a "Continued on next page" row? I've tried checking each row to see if the HeaderFormat is -1 (as I set headers to repeat on subsequent pages), but that doesn't work. I suppose I could count rows and guestimate, but I'd rather have an exact point at which to insert the new row at the bottom of the table before it breaks onto another page.
I found a solution. This post describes how to find the page number from a range. You can call this with the range of a row and check when the page changes. When the page changes go back a row index and add the "Continued..." text.

Crystal Report grouping end of page

I have a crystal reports with grouping, there are about 3 to 4 groups per page.
But at the end of the page a group is split between two pages, and sometimes there is only the group name, but the group details are on the other page.
I was wondering if there is a way to force ONLY the group that spans 2 pages to start at the next page.
I'm using the C# with visual studio 2008.
Regards,
The simple answer is to start a new page on each change of group.
There isn't an easy way to determine whether the combination of group header, group details and group footer would be split over two pages (so that you can then start a new page for the group header). The normal way to deal with this is to check the "keep together" option in each of the group sections (as described by Kangkan), and to repeat header items where necessary in page headings.
There is a complicated way to do this - by determining how much has already been printed on the current page, then calculating how large the next combined group will be and entering a conditional formula in the Group Header section against the New Page Before option. However, it is quite tricky to write and hard to maintain, as the conditional paging formula will need to be re-written if there is any change to the length of any of the sections in question.
EDIT - repeating group header items in page headers -
Say you wanted to repeat the grouping item under the column headings, where a group was split over two pages:
Split the existing page heading section into two subsections, with the column headings in the first subsection;
Add the grouping item to the second page heading subsection;
In the section expert, set the conditional formula for the Suppress (No Drill-Down) option for the second page heading subsection to be RecordNumber = 1 or Previous ({fieldname}) <> {fieldname}
There is an option to set it and it is called "Keep together". See the property page (in the section expert) for the group and check the "Keep together" option. This will solve your issue.
Also, there are options for "New page before" and "New page after" for every section. You can insert a page break accordingly.
As Mark said, it is very complicated to find out whether a group (along with its content and footer) will be accommodated in the remaining part of the page. So, the natural way is to start a group from a new page and to repeat the group in the page header if required.

is there a good way to display too much information in ASP.NET?

I find myself in a quandry that I think I know the solution to but I'd like to ask the field. I have an ASP.NET (C# 2.0 framework) page within a site which is used as a lookup. Standard gridview control, 5 columns of data, hyperlink for the 6th column to do something with record the user wants to select.
My question goes towards how to best display 'a possible' 100k records in that gridview? As it stands right now I'd sprout a few more gray hairs before it ever returns a rendered result. The gridview, for its realestate can display about 20 rows of data on the screen at a time, so paging the data still gives me 5000 pages. Adding in a rolodex-type search on A-Z the largest return set on 'J' gives me 35000 records (where alas 'X' only has 54).
Do I just break the rolodex up smaller or is there a better way to handle a situation like this?
thanks in advance!
edit: I already have the stored procedure which populates this set up for paging like GenericTypeTea suggested, again even with paging on 'J' that would give me 1750 pages. The reason I have that much data is that the amount of participants on the given auto policy. The admin needs to be able to search for a given name, or a partial. 'Jones' has 1209 records and 'Smith' has 2918 so even that makes for a rebust result set.
edit #2: added 'a possible' 100k, there is no guarentee that the account will have that many records, on the other hand it could have more :(
AutoComplete is your friend :)
Just let people enter the first 2 or 3 characters then filter your searches.
With a dataset that large I don't think paging would make that much sense.
jQuery has a nice example page AutoComplete Examples
Filters. Don't show that much data. Show the first x records. And beyond that, the user will need to be more precise with their search. Nobody will look through 100k records for the one they want. I'd limit it to a couple hundred at most (10 pages, 20 per page).
Advise the user how many results there were though, or give some clue so they know that there were many that aren't shown, and they need to be more specific in their search
It seems to me like adding search capabilities would be more efficient than filtering or paging.

Categories