.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Send report to printer from code-behind...

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :ASP.Net


I would like to create a print button to send a .rdlc report to the users printer. Since i'm not using report viewer to view my reports using it's controls is not an alternative.

I have a button that generates a .pdf file from the report, and now i would like to make a similar button, but to print the report.

Can anyone help me?

View Complete Post

More Related Resource Links

populate report viewer by code


Hi all

I have a button "Show Report" to show some data from table

what I should write under this button to populate the reports ?

Report Variable / Custom Code

I have looked through a bunch of posts and I just cannot find the answer to my issue.  All I wish to do is create a simple integer variable and increment it by 1 each time the textbox which it lives in is displayed. I have used custom code: dim Counter as integer public function SetCounter() as String     Counter +=1     return Counter.tostring() end function which works fine except for the fact that on every new page the counter is set back to 1.  If my report is 60 pages long, I don't want the variable to start with 1 on page 60. I have tried using a hidden parameter because I can access that in code but I have found no way to use something like Variables!Count.Value +=1 Any ideas are welcomed.  thank you

Iterate through rows of dataset in report's custom code

Hello, How can I iterate through the rows of a dataset in the custom code? I have a report containing a dataset. I pass the dataset as a parameter to the custom code function. But what then? Where is a reference about the available members etc.? Here is my dummy sample code so far: Public Function ShowParameterValues(ByVal ds as DataSet) as object() Dim codes() As Object Array.Resize(codes,dc.???.Count) codes(0)=ds??(field???)(row??) return codes End Function As the task I want to accomplish is very simple, I want to keep it in the custom code instead of writing any custom assemblies etc.   Thank you!

External Code Assemblies, Report Subscriptions, and configuration files

I've got a report that relies on a very small external assembly for data for one of its fields.  That assembly, in turn, relies on some values from System.Configuration for portions of its work. I have the configuration keys and values running fine in the web interface, set up in web.config, but when users set up subscriptions for the report it runs fine but doesn't retrieve the configuration values from web.config (as expected) nor does it retrieve them from rsreportserver.config, where I have tried them in the root of the config file as <add key=... /> entries and also by wrapping them inside an <appSettings /> node.  I have also tried them in an appropriately-name config file in the bin directory.  In all cases the report is fine except the field that relies on the external assembly, where I recieve an error indicating that there's missing information (the config vals are used in a String.Format() call): Value cannot be null. Parameter name: format at System.String.Format(IFormatProvider provider, String format, Object[] args) at ExternalDBFunctions.ExternalSelectors.GetNotificationStati(String NotificationID) mscorlib When I remove the config values from the web.config, the web interface shows exactly the same error. Where should these configuration values go?

Best way to send data to report server from merge replicated database

Hi ALL,              I have merge replication configured on database say Testdb on production server. I want data from testdb(merge replicated) database to send to report server. How can i accomplish this....Whts the best way to send data at regular intervals to report server.. Any suggestions plz TIA

how to send email in asp.net with attachment c# code

 SmtpClient smtpClient = new SmtpClient();         MailMessage message = new MailMessage();         try         {             MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);             // You can specify the host name or ipaddress of your server             // Default in IIS will be localhost              smtpClient.Host = "localhost";             //Default port will be 25             smtpClient.Port = 25;             //From address will be given as a MailAddress Object             message.From = fromAddress;             // To address collection of MailAddress             message.To.Add("admin1@yoursite.com");             message.Subject = "Feedback";             // CC and BCC optional             // MailAddressCollection class is used to send the email to various users   

how to send email in asp.net to any destination eg yahoo,gmail,hotmail etc c# code

hi i have try many code for sending email from msdn and many sites.but still i could do so. some code are here...   SmtpClient smtpClient = new SmtpClient();         MailMessage message = new MailMessage();           try         {             MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);               // You can specify the host name or ipaddress of your server             // Default in IIS will be localhost              smtpClient.Host = "localhost";               //Default port will be 25             smtpClient.Port = 25;               //From address will be given as a MailAddress Object             message.From = fromAddress;               // To address collection of MailAddress             message.To.Add("admin1@yoursite.com");             message.Subject = "Feedback";               // CC

How to automatically run code and send emails?

Hi all- I would like to have users set some parameters, then have routines run in the middle of the night and if the user parameters are met, have an automated email sent to update the user at various time intervals as set by user , ie daily, weekly, monthly, etc.) Can someone please point me in the right direction on how I go about doing this?    

RDL rename breaks all references to expressions and report properties code in BIDS

I have done a 'save as' in BIDS and changed the name of the file from ordreqn-lab.rdl to ordreqn-ptheader-per-order.rdl.  The report has custom code in the report properties and expressions that are based on that code.  After renaming this report I get 100 errors all rsFieldReference errors basically saying the expressions and fields are not referring to the current dataset. Version info: SQL 2008 R2. Any assistance would be greatly appreciated. I did notice there is another rename bug.  Is this a bug also and if so what is the status of a fix. Please let me know if I can provide further information. I don't see a place to attach the rdl. http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/564f5031-e832-4666-ab52-29391b74b955/

report is stuck after addition of description to code column


Hey everybody

This is rather odd and anoying..

I have a simple report with one table and some 4-5 fields in its columns.

No groups,sorts or filterring.

Every thing goes well until i add another column to report with some desccription (lets say area name).

This addition makes the report stuck..

Running the data set alone in reports data section is fine as well.

Have anyone seen this odd behavior?

Any idea what mite cause it or how should i debugg it??

Data set contains some 10,000 rows.

Thanks alot for your attention



Only send report if data exists


I am trying to solve a problem where the people set up to get subscriptions only want the report emailed if it contains data.  Currently if whatever report it is does not have any data matching the report criteria they are still emailed an empty report.  I know I could add logic that basically runs the same query as the report and if @@ROWCOUNT > 0 then I could put some logic in the actually run the report and send the subscription but as a DBA that does not make sense as that is vbasically like hitting the database twice to run the same report.


Any help would be greatly appreciated

How do I assign the return value of a async code activity to the send activity in a workflow?



Here's my scenario:

- I have a WF service with a Pick activity. 

- The pick branch contains a Sequence activity in the trigger section. 

- The sequence contains a Receive activity that receives some information from another WF service.  It then performs an async code activity called CopyFiles.  CopyFiles returns a boolean value based on if the copy was successful or not. 

- The Action section of the pick branch has a Send activity, which will send this result to the calling WF service.

- The calling WF will look at this boolean value and decide whether to move to the next step or not.


How can I pass this boolean value to the Send activity?

Below is my async CopyFiles activity:

public sealed class CopyFiles : AsyncCodeActivity<bool>
    public InArgument<Services.Application> Application { get; set; }
    public InArgument<Services.Resource> ResourceFrom { get; <

Need code for send email from enquiry form


Dear All

I need code in C# and ASP.Net for send Email from enquiry form



Using custom code on report services to check if directory does exist or not (need help)


I am trying to check if a directory does exist.  I have used the vb.net to create a very small function and embedded into the "Custom code:" section of Report Properties.  It’s output is a return of Y or N (string) or 1 or 0 (Integer) if directory exist or not. 

Here is the code which returns a String

    Function ifDirExist(ByVal mypath As String) As String

        Dim flag As String

        If Not System.IO.Directory.Exists(mypath) Then

            flag = "N"

Can I "hard-code" a particular report in the report viewer web part?


Hi there,

I am wondering if it is possible to "hard-code" a particular report in the report viewer web part, such that this report is automatically loaded when a user visits a particular site. I am asking that question because I do not want to select the same report each time I want to view it; I just would like to have a link that will get me the report right away.

Best wishes



How to not send subscription report if no data

I have a report that may or may not have data. I have a subscription setup for this report. The subscription has a defined To list. I would like to NOT send the report if there is no data on the report. I did this in SQL 2000 by raising an error from the stored procedure if there was no data. However, that approach does not seem to work with 2005. Is there another way to accomplish this?

printing 20'' X 6'' report in a regular inkjet printer


Dear Friends

how do I print  20''  X 6'' report in a regular inkjet  printer.

I know I  need to feed the 6'' side to the printer but what should be the printer settings ?

should I design each of the text field in "writingMode=tb-rl"..... when i do this I am facing problems with alignment of adjacent fields...they seem to get displayed in different parts of the report

also i have about 50 textboxes and 2 tables  in the report.

Kindly help

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend