private void Retrieve() { string convertedfrom = "2017-11-1"; string convertedto = "2017-11-30"; var dt = GetData(convertedfrom, convertedto); var objectDataSource = new ObjectDataSource { DataSource = dt }; var report = new LabelRpt { DataSource = objectDataSource }; report.DataSource = objectDataSource; var table = report.Items.Find("list1", true)[0] as Telerik.Reporting.List; table.ColumnHeadersPrintOnEveryPage = true; table.DataSource = dt; var clientReportSource = new InstanceReportSource { ReportDocument = report }; ReportViewer1.ReportSource = clientReportSource; ReportViewer1.DataBind(); ReportViewer1.RefreshReport(); }
protected void submit_Click(object sender, EventArgs e) { DateTime datez = Convert.ToDateTime(dates.SelectedDate); string convertedDate = datez.ToString("yyyy-MM-dd"); string selectedid = RadCmbTrans.SelectedValue; var dt = GetData(convertedDate, selectedid); var objectDataSource = new ObjectDataSource { DataSource = dt }; var report = new LabelRpt { DataSource = objectDataSource }; report.DataSource = objectDataSource; var table = report.Items.Find("table1", true)[0] as Telerik.Reporting.Table; table.ColumnHeadersPrintOnEveryPage = true; table.DataSource = dt; var clientReportSource = new InstanceReportSource { ReportDocument = report }; ReportViewer1.ReportSource = clientReportSource; ReportViewer1.DataBind(); ReportViewer1.RefreshReport(); RadTabStrip1.FindTabByText("Report").Enabled = true; RadTab tab1 = RadTabStrip1.Tabs.FindTabByText("Report"); tab1.Selected = true; tab1.PageView.Selected = true; }
protected void test_Click(object sender, EventArgs e) { LabelRpt report = new LabelRpt(); string convertedfrom = "2017-11-1"; string convertedto = "2017-11-30"; var dt = GetData(convertedfrom, convertedto); var objectDataSource = new ObjectDataSource { DataSource = dt }; report.DataSource = objectDataSource; var table = report.Items.Find("list1", true)[0] as Telerik.Reporting.List; table.ColumnHeadersPrintOnEveryPage = true; table.DataSource = dt; Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); Telerik.Reporting.TypeReportSource typeReportSource = new Telerik.Reporting.TypeReportSource(); typeReportSource.TypeName = "reportName"; Telerik.Reporting.Processing.RenderingResult result = reportProcessor.RenderReport("PDF", report, deviceInfo); string today = Convert.ToDateTime(DateTime.Now).ToString("ddMMyyyy"); string fileName = result.DocumentName + "_" + today + "." + result.Extension; string path = System.IO.Path.GetTempPath(); string filePath = System.IO.Path.Combine(path, fileName); TempPath.Text = filePath; using (System.IO.FileStream fs = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); } if (update(dt)) { RetrieveCombobox(); Response.Write("<script>alert('File Has been downloaded to your temporary Folder, see information above preview')</script>"); } else { Response.Write("Error has occurred"); } }