How can I trap "View Report" in ReportViewer (webforms) for SSRS? - asp.net

I am using ReportViewer.WebForms in asp.net page. I have the parameter toolbar showing up where I can select a parameter, it does a postback to get the next parameter (dependent on the first), and so forth.
When I click the View Report button there is a postback and the report will display fine.
All this works great.
What I would like to do is set the ShowReportBody to false
ReportViewer.ShowReportBody = False
At this point I would like to grab all the parameters that have been selected by the user and run the render method to export to a file (of my choosing .. maybe excel, maybe pdf .. does not really matter, nor is the topic of this question).
So, my question is, how (or can I) trap the button event of the View Report button? I would like to be able to use the ReportViewer UI in order to capture all the parameters instead of building custom parameters.
I'd also like to rename this, but, again .. another topic :)

You can use the IsPostBack flag and QueryString
Example:
Viewer.ShowReportBody = false
if(IsPostBack)
{
if(Request.QueryString["Exec"] = "Auto")
Viewer.ShowReportBody = true;
...
}
else
{
Viewer.ShowReportBody = true;
}

Related

Open print dialog for report from code

I am attempting to force open the print dialog so that all the user has to do is set the email address and press ok. I've found multiple tutorials on how to print a report to file or a printer without the print dialog, but that's not what I'm looking for.
Typically to email a report, the user displays the report, clicks the print icon in the tool bar, and then chooses email and sends it. I want to cut out the first two steps automatically.
This is one of my many attempts at doing this so far, but to no avail.
void emailInvoice()
{
Args args;
ReportRun rr;
Report rb;
PrintJobSettings pjs;
CustInvoiceJour record;
;
select record where record.RecId == 5637175089;
args = new Args("SalesInvoice");
args.record(record);
args.parmEnum(PrintCopyOriginal::OriginalPrint);
// Set report run properties
rr = new ReportRun(args,'');
rr.suppressReportIsEmptyMessage(true);
rr.query().interactive(false);
// set report properties
rb = rr.report();
rb.interactive(true);
// set print job settings
pjs = rr.printJobSettings();
pjs.fileName(strfmt("C:\\Users\\gbonzo\\Desktop\\%1.pdf", record.SalesId));
pjs.fitToPage(true);
// break the report info pages using the height of the current printer's paper
pjs.virtualPageHeight(-1);
// force PDF printing
pjs.format(PrintFormat::PDF);
pjs.setTarget(PrintMedium::Mail);
pjs.viewerType(ReportOutputUserType::PDF);
// lock the print job settings so can't be changed
// X++ code int the report may try to change the destination
// to the screen for example but this does not make
// sense when running a report here
pjs.lockDestinationProperties(true);
// Initialize the report
rr.init();
rr.run();
}
Thanks in advance for your help!
Have you tried to develop a RunBase standard dialog class (RunBaseBatchPrintable if you need to select the printer) that get all the dialog fields you need and from there, programatically run the report passing all the desired parameters? I'm prety sure it will work, and probably will left a cleaner code separating the report of the logic needed to the user interaction.
Read an example here:
http://waikeatng.blogspot.com.es/2010/10/using-runbasebatchprintable-class.html
You have to call the prompt() method of the ReportRun class before calling the run() method.
if (rr.prompt())
{
rr.run();
}
The prompt() method will show the print dialog. If you want it easier for your users you could use the SysMailer class, take a look to the quickSend() method.

report viewer didn't show reports

I try to view reports in my report viewer but it show nothing
my on load function where the report viewer is
like :
if(!IsPostBack)
{
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = "Reports/MainReport.rdlc";
DataTable orderDt = controller.SelectFullOrderDetailsInfo(orderID);
ReportDataSource rptds = new ReportDataSource("OrderInfo", orderDt);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rptds);
ReportViewer1.LocalReport.Refresh();
ReportViewer1.DataBind();
}
Report viewer page just run empty and didn't show any thing ! what I'm missing
I know my reply is 5 years after the question is asked :), but I put my findings here, hopefully, it will save time for others in the future.
Recently I have done 60 reports for my company. Bellow are causes of a report not showing:
1: Most Frequent case: You report has parameters which can be empty or null. If you have parameters make sure you specify that those parameters can accept empty or null values, otherwise re[rot shows as empty. To verify, remove all parameters from the report and run it without any parameters.
2: Check rptds Table(report DataSource) to make sure it is populated.
3: (This one happened to a couple of times). Browse your code to make sure you do not set the report viewer visibility to false.

updatepanel doesnt update correctly, must click twice to update

I am using an update panel and when I click a button it will update all the panels.
updapanel1.update() is very simple, but my data is not updating unless I hit the button twice.
My gridviews shows data for a selected user, and then all the grids reflect that users data.
works fine all the update panels work for the gridviews.
Now for somereason when i try to do a row count and update the panel with the summary, it does not work, i get either the previous users summary or if i hit update again for the same user i get the correct data.
'the grids are in these panels
UpdatePanel1.Update()
UpdatePanel2.Update()
UpdatePanel4.Update()
UpdatePanel6.Update()
UpdatePanel7.Update()
'the things that are not updateing correctly
rqnum.Text = GridView3.Rows.Count
oknum.Text = GridView4.Rows.Count
xlnum.Text = GridView5.Rows.Count
dynum.Text = DataList1.Items.Count
UpdatePanel8.Update()
Panel1.Visible = False
Without seeing the code for this we cannot guarantee that we are giving you the right answer, but just a thought. If the code you posted is the actual code, I would re-order things a bit.
Do the updates to the content
Then call "update" on the panels
This ensures that your content updates are actually sent to the panels. My guess is this is why it takes that second click. So something like this.
'Update content and toggle visibility of controls
rqnum.Text = GridView3.Rows.Count
oknum.Text = GridView4.Rows.Count
xlnum.Text = GridView5.Rows.Count
dynum.Text = DataList1.Items.Count
Panel1.Visible = False
'Now update all needed panels
UpdatePanel1.Update()
UpdatePanel2.Update()
UpdatePanel4.Update()
UpdatePanel6.Update()
UpdatePanel7.Update()
UpdatePanel8.Update()

Loading extJS Combo Remotely not Working

This is my first bash at using extJS, and after a few hours of struggling, some things are working OK, except I have combo lists that I can't filter down to less than 2000 items in edge cases, so I'm trying to page the lists through remotely, but I must be doing something wrong.
My data store and combo look as follows:
var remoteStore = new Ext.data.JsonStore({
//autoLoad : true,
url : 'addition-lists.aspx',
fields : [{name: 'extension_id'}, {name: 'extension'}],
root : 'extensionList',
id : 'remoteStore'
});
.
.
xtype : 'combo',
fieldLabel : 'Remote',
name : 'remote',
displayField : 'extension',
valueField : 'extension_id',
mode : 'remote',
//pageSize : 20,
triggerAction : 'query',
typeAhead : true,
store : remoteStore,
anchor : '95%'
The combo works loading locally, but as soon as I switch to remote it remains blank.
My ASP.NET page returning the JSON is like this:
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.Write(GetRemote());
}
On remote stores the combo defaults its minChars property to 4, so the query only gets sent after typing 4 chars. Setting minChars almost gives the desired behaviour.
I say almost because even if the item sought by autocomplete is in the current page, a new server query still gets sent, defaulting the selection to the first item in the new page.
The way you configured your store above, the result from your ASP script should read something like this:
{"extensionList": [
{"extension_id": 1, "extension": "js"},
{"extension_id": 2, "extension": "aspx"}
]}
If it doesn't look like that, your remote store will not find anything.
You can refer to this question ExtJS combobox problem in IE
Several things. First, when doing this:
remoteStore.loadData(<%= GetRemote() %>);
you are not actually making a remote call from your javascript. You are echoing the result of calling the GetRemote server function directly into the page at render time. Probably not what you intend? If GetRemote is writing out your combo data (and it's working correctly), then you should be able to use a combo setup for local data. If the intention really is to make a remote call, then you need to remove the server tag and load data via the proxy url as shown in several examples that come with Ext.
Another thing is that your Page_Load code doesn't actually show anything about how you are loading, formatting or returning your data. I would suggest viewing source and verifying that your tag is actually being replaced with the data you expect. If/when you switch it to a true remote call to load data then you can use Firebug to inspect your XHR calls and verify the data coming down that way.
You must set a proxy, i.e. set
proxy: new ScriptTagProxy
property for loading 'store' remotely. Look at examples for exact syntax.
EDIT: Please disregard my previous note since you're using JsonStore shortcut.
Try to apply all of these properties to your combo:
typeAhead: true,
typeAheadDelay: 500,
triggerAction: 'all',
selectOnFocus:true,
And please do not do server-side prefetch of records (using loadData). It hurts internal filter very much, so that you stick with filtered records from different prefetches.
On the other hand, if you do prefetch all records on the server-side, why do you need then remote access for your combo anymore?!

ASP.Net links won't disable if done during postback

I'm still fairly new to ASP.Net, so forgive me if this is a stupid question.
On page load I'm displaying a progress meter after which I do a post back in order to handle the actual loading of the page. During the post back, based on certain criteria I'm disabling certain links on the page. However, the links won't disable. I noticed that if I force the links to disable the first time in (through debug) that the links disable just fine. However, I don't have the data I need at that time in order to make the decision to disable.
Code Behind
If (Not IsCallback) Then
pnlLoading.Visible = True
pnlQuote1.Visible = False
Else
pnlLoading.Visible = False
pnlQuote1.Visible = True
<Load data from DB and web service>
<Build page>
If (<Some Criteria>) Then
somelink.Disable = True
End If
End If
JavaScript
if (document.getElementById('pnlQuote1') === null) {
ob_post.post(null, 'PerformRating', ratingResult);
}
ob_post.post is an obout js function that does a normal postback and then follows up with a call to the server method named by the second param. then followed by the call to a JavaScript method named by the third param. The first parameter is the page to post back to. A value of null posts back to the current page.
The post back is working fine. All methods are called in the correct order. The code that gives me trouble is under the code behind in bold. (somelink.disabled = True does not actually disable the link) Again, if I debug and force the disabling of the link to happen the first time in, it disables. Does anyone know what I might do to get around this?
Thanks,
GRB
Your code example is using the IsCallBack check, while the question text talks about the IsPostback Check. I'd verify that you're using Page.IsPostBack in your code to turn off the links.

Resources