or
<?xml version="1.0" encoding="utf-8"?><Report DataSourceName="TestConn" Width="6.45833333333333in" Name="Parent"> <DataSources> <SqlDataSource ConnectionString="" SelectCommand="SELECT ID, CreateDate FROM tblTest WHERE ID= 1234" Name="TestConn" /> </DataSources> <Items> <PageHeaderSection Height="0.28125in" Name="pageHeader"> <Items> <TextBox Value="Parent" Size="6.41666666666667in, 0.200000027815501in" Location="0.0208333333333333in, 0.0208333333333333in" Name="reportNameTextBox" StyleName="PageInfo" /> </Items> </PageHeaderSection> <PageFooterSection Height="0.28125in" Name="pageFooter"> <Items> <TextBox Value="=NOW()" Size="3.19791666666667in, 0.200000027815501in" Location="0.0208333333333333in, 0.0208333333333333in" Name="currentTimeTextBox" StyleName="PageInfo" /> <TextBox Value="=PageNumber" Size="3.19791666666667in, 0.200000027815501in" Location="3.23958333333333in, 0.0208333333333333in" Name="pageInfoTextBox" StyleName="PageInfo"> <Style TextAlign="Right" /> </TextBox> </Items> </PageFooterSection> <ReportHeaderSection Height="1.0290683110555in" Name="reportHeader"> <Items> <TextBox Value="Parent" Size="6.45833333333333in, 0.787401596705119in" Location="0in, 0in" Name="titleTextBox" StyleName="Title" /> <TextBox Value="Create Date:" CanGrow="True" Size="3.19791666666667in, 0.200000027815501in" Location="0.0208333333333333in, 0.808234930038452in" Name="createDateCaptionTextBox1" StyleName="Caption"> <Style TextAlign="Right" /> </TextBox> <TextBox Value="=Fields.CreateDate" CanGrow="True" Size="3.19791666666667in, 0.200000027815501in" Location="3.23958333333333in, 0.808234930038452in" Name="createDateDataTextBox" StyleName="Data" /> </Items> </ReportHeaderSection> <ReportFooterSection Height="0.28125in" Name="reportFooter" /> <DetailSection Height="0.28125in" Name="detail"> <Items> <TextBox Value="=Fields.CreateDate" CanGrow="True" Size="1.58854166666667in, 0.200000027815501in" Location="0.0208333333333333in, 0.0208333333333333in" Name="createDateDataTextBox1" StyleName="Data" /> <TextBox Value="=Fields.ID" CanGrow="True" Size="1.58854166666667in, 0.200000027815501in" Location="1.63020833333333in, 0.0208333333333333in" Name="iDDataTextBox" StyleName="Data" /> </Items> </DetailSection> </Items> <StyleSheet> <StyleRule> <Style Color="28, 58, 112"> <Font Name="Tahoma" Size="18pt" /> </Style> <Selectors> <StyleSelector Type="ReportItemBase" StyleName="Title" /> </Selectors> </StyleRule> <StyleRule> <Style BackgroundColor="28, 58, 112" Color="White" VerticalAlign="Middle"> <Font Name="Tahoma" Size="10pt" /> </Style> <Selectors> <StyleSelector Type="ReportItemBase" StyleName="Caption" /> </Selectors> </StyleRule> <StyleRule> <Style Color="Black" VerticalAlign="Middle"> <Font Name="Tahoma" Size="9pt" /> </Style> <Selectors> <StyleSelector Type="ReportItemBase" StyleName="Data" /> </Selectors> </StyleRule> <StyleRule> <Style Color="Black" VerticalAlign="Middle"> <Font Name="Tahoma" Size="8pt" /> </Style> <Selectors> <StyleSelector Type="ReportItemBase" StyleName="PageInfo" /> </Selectors> </StyleRule> </StyleSheet> <PageSettings> <PageSettings PaperKind="Letter"> <Margins> <MarginsU Left="1in" Right="1in" Top="1in" Bottom="1in" /> </Margins> </PageSettings> </PageSettings> <Groups> <Group Name="labelsGroup"> <GroupHeader> <GroupHeaderSection PrintOnEveryPage="True" Height="0.28125in" Name="labelsGroupHeader"> <Items> <TextBox Value="Create Date" CanGrow="True" Size="1.58854166666667in, 0.200000027815501in" Location="0.0208333333333333in, 0.0208333333333333in" Name="createDateCaptionTextBox" StyleName="Caption" /> <TextBox Value="ID" CanGrow="True" Size="1.58854166666667in, 0.200000027815501in" Location="1.63020833333333in, 0.0208333333333333in" Name="createIDCaptionTextBox" StyleName="Caption" /> </Items> </GroupHeaderSection> </GroupHeader> <GroupFooter> <GroupFooterSection Height="0.28125in" Name="labelsGroupFooter"> <Style Visible="False" /> </GroupFooterSection> </GroupFooter> </Group> </Groups></Report><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <telerik:RadCodeBlock runat="server"> <script type="text/javascript"> ReportViewer.prototype.PrintReport = function() { this.PrintAs("Default"); } function MyPrint() { <%=ReportViewer1.ClientID %>.PrintReport(); } </script> </telerik:RadCodeBlock> <script type="text/javascript"> ReportViewer.OnReportLoadedOld = ReportViewer.OnReportLoaded; ReportViewer.prototype.OnReportLoaded = function () { this.OnReportLoadedOld(); var printButton = document.getElementById("PrintButton"); printButton.disabled = false; } </script></head><body> <form id="form1" runat="server"> <asp:ScriptManager runat="server" /> <div> <asp:Button ID="Button1" runat="server" Text="Print" OnClick="Button1_Click" Style="width: 41px" /> <asp:Button ID="PrintButton" runat="server" Text="Print Dialog Server" OnClick="PrintButton_Click" /> <asp:Button ID="PrintClient" runat="server" Text="Print Client" OnClientClick="MyPrint(); return false;" /> <telerik:ReportViewer ID="ReportViewer1" runat="server" Width="100%" Height="800px" Style="display:none"></telerik:ReportViewer> </div> </form></body></html>public partial class Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = new Report1(); this.ReportViewer1.ReportSource = instanceReportSource; } protected void Button1_Click(object sender, EventArgs e) { ExportToPDF(new Report1()); } void ExportToPDF(Telerik.Reporting.Report reportToExport) { ReportProcessor reportProcessor = new ReportProcessor(); Telerik.Reporting.InstanceReportSource instanceReportSource = new Telerik.Reporting.InstanceReportSource(); instanceReportSource.ReportDocument = reportToExport; Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, null); string fileName = result.DocumentName + "." + result.Extension; Response.Clear(); Response.ContentType = result.MimeType; Response.Cache.SetCacheability(HttpCacheability.Private); Response.Expires = -1; Response.Buffer = true; Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"", "attachment", fileName)); Response.BinaryWrite(result.DocumentBytes); Response.End(); } protected void PrintButton_Click(object sender, EventArgs e) { string printScript = string.Format("{0}.PrintReport();", this.ReportViewer1.ClientID); this.ClientScript.RegisterStartupScript(this.GetType(), "ReportPrint", printScript, true); } }
var products = Products.Where(x => x.IsSelected);
Custom business object
DistributionCompilation distribution = new DistributionCompilation();
Populating the business object
distribution.BuildSingleBrandDistributionRport(products, SelectedStart, SelectedEnd, MinBottles, NoBuyPeriod, SelectedBrand.Name);
Setting it as the source for the report
NewDistributions distribution_report = new NewDistributions();
distribution_report.DataSource = distribution.ShowReport();
_View.Report = distribution_report;