Uma (whoever that is) has posted a question in response to https://spacefold.com/lisa/2007/09/19/Dynamically-loading-reports-in-ReportViewers , which as far as I can tell is completely unrelated to that post <g>.
Hi i want to display subtotal of first page in the top of next page in rdlc report and i am using page break of 10 in every page.
Unrelated to dynamically loading reports or not, the question certainly covers a subject that I'm familiar with and will address here in case I haven't in the past.
First, just in case I haven't already talked about conditional page breaks on <item number>, this is just a variant of other ROW_NUMBER() techniques we've used to resolve past problems. Let's say my SQL query looks something like this, in Uma's case:
SELECT
Sales_No, Customer,Order_Quantity,
CEILING(CAST( ROW_NUMBER() OVER (ORDER BY Customer) / 10 AS
Numeric(10,2))) AS Grouper
FROM OrderHeader
ORDER BY Customer
… where the "/10" in the above query is determined by the "page break of 10" in Uma's scenario. OK so far?
So now my group break is simply the expression =Fields!Grouper.Value, and I set this group to page break at end.
NB: I always think it's nice to let SQL do most of the work, if I can.
In your situation, you might be doing it differently, or in a more RS-oriented way. That's okay, how you happen to be determining your page break is not really germane to Uma's question at all. The point is, however you're doing your grouping… the work is almost all done already. It looks as though we have a lot of work left, maybe, but really, it's almost done.
So now let's say we have a subtotal expression (for Uma) that, in my example, looks like this, in the footer of this group: =Sum(Fields!Order_Quantity.Value).
And let's say we change that footer expression to do this: =Sum(Fields!Order_Quantity.Value) & Code.MyUdf(Sum(Fields!Order_Quantity.Value)).
And let's say we write the following (really minimal) amount of code:
Public PrevPage As Double = 0
Function MyUdf( t As Double) AS String
PrevPage = t
Return ""
End Function
… and now let's say we put a textbox in the group header with the following expression: =IIF(Code.PrevPage = 0,"",Code.PrevPage) (the IIF() is just to take care of the first page, because I'm too lazy to worry about whether this is the most elegant way to do it or not).
That's all she wrote, folks. Seems to work just as you'd want. No big deal, really.
Why the title of this post?
First, you should know it's a quote from "Little Big Man". I'm taking a "Serenity" break, just for kicks.
Second, this is one of those times when multiple export types (Excel rendererer, PDF renderer, etc) don't get in the way. You notice I haven't put anything in the page header; I'm avoiding any issues of "what sequence does everything happen in" in the various rendering engines that way. Sometimes the magic can… just work.
hi i have written the same code but its giving error as
Error 1 There is an error on line 1 of custom code: [BC30183] Keyword is not valid as an identifier. C:\Inetpub\wwwroot\WebSite5\Report.rdlc 1
Error 2 The Value expression for the textbox ‘OrderID_2’ contains an error: [BC30456] ‘u’ is not a member of ‘ReportExprHostImpl.CustomCodeProxy’. C:\Inetpub\wwwroot\WebSite5\Report.rdlc 1
Error 3 The Value expression for the textbox ‘textbox13’ contains an error: [BC30456] ‘u’ is not a member of ‘ReportExprHostImpl.CustomCodeProxy’. C:\Inetpub\wwwroot\WebSite5\Report.rdlc 1
i think we should use assembly reference which assembly can i use for this code.
Thanks & Regards
You don’t need an assembly reference. If I had needed one, honestly, I would have mentioned it <g>.
I can’t really help you, though, because I have no idea what “u” is. What exactly in the Value expression for the textbox OrderID_2 in your RDLC, should we maybe start from there? I guess I should ask (just in case) exactly where in your RDLC is the textbox situated?
And when you say you wrote “the same code”, exactly what did you write?
hi i have written this code
Public Double P=0
Public String Myfun(Double t)
{
P=t
Return t
}
this is in table subtotal field “=Code.Myfun(Sum(Fields!OrderID.Value))” and this is in header textbox
“=IIF(Code.P = 0,””,Code.P)” and the error is
Error 1 There is an error on line 0 of custom code: [BC30183] Keyword is not valid as an identifier. C:\Inetpub\wwwroot\WebSite5\Report.rdlc 1
actually i want like this
page 1
name acc bal
a 6 10
b 7 20
sutotal 30
page 2
subtotal of first page 30
name acc bal
aa 6 10
bb 9 60
sutotal 70
page 3
subtotal of second page 30
Thanks
This is VB, Uma. No curley braces.
Hi i have written vb code only its displaying subtotal in the first page but in the next page its not displaying subtotal of previous page why…plz reply me.
Thanks
hi this code does not return previous page subtotal in the next page.
actually i am working in c#.net is this code correct or not.
hi pls send c# code
hi its working but not displaying anything in the subtotal textbox and in the next page .
First, you cannot write the code in C#.
Second, in which header is your textbox? And exactly which footer is your expression invoking the function in? They should be on the same group level as is forcing the group break.
Hi i knw we can’t write c# code. ur code is working but the expression =IIF(Code.PrevPage = 0,””,Code.PrevPage) it will take PrevPage value as 0 bez we declared as Public PrevPage As Double = 0 it will not display previous page subtotal.
Actually i am calling the function within the table(group level with page break ) there its displaying subtotal we can do this subtotal by grouping only and i m adding one header there using one textbox with in that i m using this =IIF(Code.PrevPage = 0,””,Code.PrevPage).plz… give me solution bez. they r firing us.
Thanks
Uma, I am trying to give a solution — and my code works, honestly, I didn’t post without testing.
You are making a mistake about this:
>>bez we declared as Public PrevPage As Double = 0 it will not display previous page subtotal.
If you think this declaration takes place once per page, you’re wrong. Once you’ve declared it you can fill it with other values during the run of the report. If you put the calls to the variable at the right moments, it will have the right value on every page.
Once again:
IN WHICH HEADER is your textbox? Which header band exactly?
hi i am using that declaration with in the page header and also i used one textbox with in the body and i used there also but it is not displaying anything.
Please notice where I put the expressions in my example, Uma,
>>
and now let’s say we put a textbox in the group header with the following expression: =IIF(Code.PrevPage = 0,””,Code.PrevPage)
<<
I think you might be able to put it in an outer group footer, if you need to, but you can’t just put it anywhere you want and have it work.
Think (as always) about the sequence in which events happen during report processing and you’ll probably understand the difference. Page headers and footers are processed separately. The body, outside the table, is processed separately. This may also be true of the table header and footer (even if they are *printed* on each page of the report) — I haven’t tested that recently.
Likewise, just to be sure you pay attention to this, notice that in my example the expression passing the value to the variable is, in the footer for this group. Not just “anywhere”.
Hi thanks a lot mam its working thank u so much.
Yours,
Hi dn’t feel anything i have another doubt how can i do carry forward data in reports in the same report and i cn’t able to do stored procedure in rdlc plz…. give some solution.
Yours,
Uma, I’m not sure what you mean by “I cn’t able to do stored procedure in rdlc” because you don’t access the data from within the RDLC. In local modes you access the data *outside* the RDLC and hand the data set to the RDLC.
You’ll see some examples of binding the data dynamically for different needs here http://spacefold.com/lisa/Dynamically-loading-reports-in-ReportViewers. You get a dataset from a SQL Server (or also, in that page’s examples, from a SQL Server CE instance or from an XML file) using standard syntax that inclues the ability to invoke a stored procedure.
As for your other question, whether or not I “feel” anything about it is not important, but I can’t answer it because I haven’t any idea what you are asking for help with.
I have done similar carryover operations in programs like Excel. It doesn’t work as smoothly as this though.