Showing posts with label RDLC. Show all posts
Showing posts with label RDLC. Show all posts

Monday, January 19, 2009

Adding dynamic hyperlinks in the Report Viewer; ASP.Net Reports

Adding dynamic hyperlinks in the Report Viewer; ASP.Net Reports

Type the text to be displayed as the Hyperlink in the cell of your Table control added in the RDLC file. Right click on the Hyperlink text cell and click 'Navigation' tab.

Click Jump to URL radio button and add expression by clicking 'fx' button.

=iif(1<>0, Parameters!MyLink.Value+"?qBTchId=" & Fields!BatchID.Value, "")
Report Parameters can be sent from the code behind file as

Microsoft.Reporting.WebForms.ReportParameter RptLink1 = new Microsoft.Reporting.WebForms.ReportParameter("AssignLink", UriBuilder.BuildUrlNew(@"../Training/FrmAssignTraining.aspx"));
Microsoft.Reporting.WebForms.ReportParameter RptLink2 = new Microsoft.Reporting.WebForms.ReportParameter("UpdateLink", UriBuilder.BuildUrlNew(@"../Training/FrmTrainingUpdate.aspx"));
Microsoft.Reporting.WebForms.ReportParameter RptLink3 = new Microsoft.Reporting.WebForms.ReportParameter("PrintLink", UriBuilder.BuildUrlNew(@"../Training/FrmTrainingPrint.aspx"));

RptTraining.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { RptLink1, RptLink2, RptLink3 });

RptTraining.LocalReport.EnableHyperlinks = true;


=iif(1<>0,Fields!Status.Value, "")
******************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

///
/// The common class for building the URL for the report. Eg: UriBuilder.BuilUri("FrmAdvance.aspx");
///
public class UriBuilder
{
public UriBuilder()
{
//
// TODO: Add constructor logic here
//
}
///
/// This method Builds the physical Url with the page name provided
///
/// The name of the page
/// The URL string
public static string BuildUrl(string pageName)
{
Uri uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
Uri newUri = new Uri(uri, pageName);
return newUri.AbsoluteUri;
}

public static string BuildUrlNew(string pageName)
{
Uri uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri.Replace("/FeedBackQuality", ""));
Uri uri2 = new Uri(
Uri newUri = new Uri(uri, pageName);
return newUri.AbsoluteUri;
}
}


Wednesday, December 3, 2008

Invoking "Save as PDF" method of Report Viewer

UserEntryFormEntity oEnt= new UserEntryFormEntity();
List oEntity = new List();

oEnt = GetReportData(JoinersId); // Method Which returns a List of Data
oEntity.Add(oEnt);

Microsoft.Reporting.WebForms.LocalReport localReport = new Microsoft.Reporting.WebForms.LocalReport();
localReport.ReportPath = Server.MapPath("~/DocumentTemplates/UserEntryForm.rdlc");

Microsoft.Reporting.WebForms.ReportDataSource oDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("UserEntryFormEntity", oEntity);
localReport.DataSources.Add(oDataSource);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo = "" + " PDF" + " 8.5in" + " 11in" + " 0.5in" + " 1in" + " 1in" + " 0.5in" + "";
Microsoft.Reporting.WebForms.Warning[] warnings;
//Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
//Clear the response stream and write the bytes to the outputstream
//Set content-disposition to "attachment" so that user is prompted to take an action
//on the file (open or save)
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
Response.BinaryWrite(renderedBytes);
Response.End();

Friday, June 20, 2008

ASP.Net Report Control.

Writting conditions in the columns; Report Control, ASP.Net.

=IIf(IsNothing(Fields!Value.Value),"NA",Fields!Value.Value)This one check if the value is Null or not.If Value is Null, it displays NA
Else it displays the Value from the Business Entity.