Click here to Skip to main content
Click here to Skip to main content

Binding DataSet and Generic *.rdlc Reports to a ReportViewer at Runtime

By , 25 Jul 2006
 

Introduction

In order to display a report by using ReportViewer Control, we need a DataSource that contains the data to be shown and a Report document that describes how that data should be displayed.

This article presents how to form a Report Display Component to display data within different DataSet objects that are described by a Report document (*.rdlc).

During my previous searches about displaying data within generic DataSet objects, I've encountered a set of different solutions. Most of them assumed DataSet objects are accessible during design time. Some others used TableAdapter objects that include SQL statements and/or Connection strings, etc. Probably, these solutions cover most of the situations a developer can encounter. But what if you don't have access to DataSet objects during design time, what if the overall architecture of the software doesn't let you to use SQL statements or connection strings on the architectural level you are currently working, what if you need to use data without knowing its structure until runtime, what if you need dynamic data sources rather than static?

I'm currently in need of a component that displays generic reports. My organization is developing accounting software and in accounting domain there are lots of changes in reports. After distributing and deploying the software, organization must give supporting service about newly added or changed reports. In the maintenance phase, it is costly to distribute a whole update that often. So what we need is some kind of a Report Import / Generic Report Display ability.

Before We Begin

As I've said before, in order to display a report, we need a DataSource (in this article, a populated DataSet instance) and a report document (*.rdlc file ). Once we have the Report-DataSet pair, we can display any report we want.

Logical representation of the Report Display Component

Figure 1a: Logical representation of the Report Display Component

How Do We Use DataSet as a Data Source?

A DataSet is an object that includes tabular data which can be represented by using XML format. What we need to know is that the structure of the data can be described by an XSD schema document which is also another XML based document.

DataSet <code>dsHesapPlan = new DataSet();

//...
//... Some code to populate data within the DataSet dsHesapPlan
//...

// Set the name of the DataSet which will be useful later
dsHesapPlan.DataSetName = "HESAP_PLAN";

// Can be used to write the of the DataSet
dsHesapPlan.WriteXmlSchema();

// Can be used to write the data within the DataSet as XML
dsHesapPlan.WriteXml();

Figure 1.b: Useful operations on a DataSet

Let's take a look at the schema of the DataSet, which we get by running the method dsHesapPlan.WriteXmlSchema():

Sample DataSet Schema which will be useful when designing the report.

Figure 1.c: Sample DataSet Schema which will be useful when designing the report.
Highlighted areas show naming information that will be used later.

What is a *.rdlc Report Document?

An rdlc Report Document is also another XML based document that defines how the data should be displayed. I'm not going to demonstrate how to form a report here. But there are some things you should know, so I'll form a checklist of actions to build a report.

  1. Form a schema of the DataSet which you will use (dsHesapPlan.WriteXmlSchema()).
  2. Add the schema to your Visual Studio Project. The schema will be visible within the Data Sources window.
  3. By using this schema, design your report.
  4. After you complete designing the report, save the project.
  5. Inside your project folder, you'll find the *.rdlc report document. Take it for redistribution.

Here is a part of the structure of a *.rdlc Report Document:

Sample .rdlc Report Document

Figure 1.d: Sample *.rdlc Report Document.
Highlighted areas show naming information which must show consistency with your DataSet definitions.

How to Bind a DataSet-Report Pair?

So, now we have a Report and a DataSet that can be bundled and sent to the client. Now what we need is a system to know what to do with this DataSet-Report pair.

Note that, you can send the report as the *.rdlc file itself. And DataSet can be distributed in a set of different ways. For example, executing CREATE scripts in client side to generate STORED PROCEDUREs that return the data forming the desired DataSet, or, by XML data itself, etc.

This part of the article assumes you have the properly designed Report document and the DataSet.

The following code shows how to bind a Report-DataSet pair to a ReportViewer object dynamically.

// A method to populate data inside the referenced DataSet
getDataSet(ref <code>dsHesapPlan);

// Set the path of the rdlc document
string reportPath = "Reports/AccountReport.rdlc";

// Initiate ReportViewer object
ReportViewer rView = new ReportViewer();
rView.Dock = DockStyle.Fill;
this.Controls.Add(rView);

// Add data source to the local report
// Note that the name should either be passed as parameter or 
// parsed from the report document
rView.LocalReport.DataSources
       .Add(new ReportDataSource("HESAP_PLAN_dtLast", dsHesapPlan.Tables[0]));

// Set the active report path of the ReportViewer object
rView.LocalReport.ReportPath = reportPath;

Figure 1.e: How to bind the DataSet and the generic Report dynamically.

Conclusion

This technique may be useful for developers experiencing similar problems with me. Surely, it is possible to build a real smart system to understand and display a report. I hope this article guides efforts for building such a system.

You may visit www.rdleditor.com for a series of related links.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

DIren
Web Developer
Turkey Turkey
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionI want to display in reportViexer1 report.rdlc data from a xml file with VB.net if possible Pinmemberelmeksoaui110 Mar '11 - 12:49 
I want to display in reportViexer1 report.rdlc data from a xml file with VB.net if possible
 
thank you.
NewsHave you checked out the RDLReportViewer control... Pinmemberchris17516 Apr '10 - 18:18 
The RDLReportViewer[^] control is a control that shows RDL files without having SQL Server Reporting Services. The only property that you need to set on the control is the RDL file name. All the parameters will automatically be displayed[^], and all the datasets will automatically get loaded into the report. If the report needs to get changed, then simply change the rdl file and you're done. Check it out...
Chris

QuestionRemote Report PinmemberAcidAndroid17 Dec '08 - 12:04 
Hi It's me again sorry for the troubles
 
I read the rdlc as a xmldocument to get the datasets and a tables in order to use those data to create a Datasoruce.
I do this with the reportviwer.localreport.reportpath("file.rdlc") and read the rdlc as xml this a Xmldocument.read("filepath")
The problem I have is that now I want to do the same with a server report using reportviwer.serverreport.reportpath("http://localhost/file.rdlc")
To read a remote xml i use:
 
Dim wr As Net.HttpWebRequest = CType(Net.WebRequest.Create("http://localhost/file.rdlc"), Net.HttpWebRequest)
wr.Timeout = 10000
Dim resp As Net.WebResponse = wr.GetResponse()
Dim stream As Stream = resp.GetResponseStream()
Dim reader As XmlTextReader = New XmlTextReader(stream)
reader.XmlResolver = Nothing
ds2.ReadXml(reader)
But i get an Exception saying that "error 404 server not found", However if i change "http://localhost/file.rdlc" for "http://localhost/file.xml" i Dont get any Exception and i get the xml structure.
 
How could I read the rdlc file as remote xml?
Thanks a lot.
AnswerRe: Remote Report PinmemberDIren17 Dec '08 - 20:50 
GeneralRe: Remote Report Pinmemberdg782 Sep '09 - 4:42 
GeneralRe: Remote Report PinmemberDIren2 Sep '09 - 5:36 
QuestionReport is ok but subreport PinmemberAcidAndroid12 Dec '08 - 8:57 
Hi DIren
 
I have done a report class based on your ideas and article but when i try to load a subreport i dont know how to pass the same dataset to subrepor i can see the data in the main rerpot but in the subreport a get a error.
here is my code and Im filling the dataset with a xml file just for test:
 
Dim rds As New ReportDataSource
Dim nlist As Xml.XmlNodeList
Dim d As New Xml.XmlDocument
Dim dsname As String = Nothing
Dim dstable As String = Nothing

d.Load("D:\Orders.rdlc")
ds.Reset()
ds.ReadXml("D:\SubreportInList\Orders.xml")
 
'I get the data for the datasource from the rdlc file
 
nlist = d.GetElementsByTagName("DataSet")
 
Me.rprtv1.LocalReport.DataSources.Clear()
 
For Each nodo As Xml.XmlNode In nlist
dsname = nodo.Attributes("Name").Value
For Each ele As Xml.XmlElement In nodo
If ele.Name = "rd:DataSetInfo" Then
dstable = ele.Item("rd:TableName").InnerText
Exit For
End If
 
Next
If dsname <> "" And dstable <> "" Then
Me.rprtv1.LocalReport.DataSources.Add(New ReportDataSource(dsname, ds.Tables(dstable)))
End If
Next
 
Until this i can fill the report with the proper data but how couli do it with a subrport
Thanks for your time and patience
AnswerRe: Report is ok but subreport PinmemberDIren12 Dec '08 - 9:17 
GeneralRe: Report is ok but subreport PinmemberAcidAndroid17 Dec '08 - 13:32 
GeneralSome problems Pinmember_str_618 May '08 - 5:44 

DataRow dr;
DataTable dt = new DataTable();
dt.Columns.Add();
dt.Columns.Add();
Random rand = new Random(10000);
 
for (int i = 0; i < 100; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = rand.Next();
dt.Rows.Add(dr);
}
DataSet ds = new DataSet();
ds.Tables.Add(dt);
ds.DataSetName = "ggg";
ds.WriteXmlSchema(@"c:\scheme");
ds.WriteXml(@"c:\scheme1");
string reportPath = @"C:\Documents and Settings\...\Report1.rdlc";//full path
Microsoft.Reporting.WinForms.ReportViewer rv = new Microsoft.Reporting.WinForms.ReportViewer();
rv.Dock = DockStyle.Fill;
this.Controls.Add(rv);
 
rv.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("ggg", ds.Tables[0]));
rv.LocalReport.ReportPath = reportPath;
rv.RefreshReport();

In the issue I receive an empty ReportViewer...
Help!!! May be I forget about something
GeneralRe: Some problems PinmemberDIren14 May '08 - 22:30 
GeneralRe: Some problems PinmemberHari Om Prakash Sharma6 Jul '08 - 20:30 
GeneralRe: Some problems PinmemberDIren7 Jul '08 - 0:55 
GeneralRe: Some problems PinmemberHari Om Prakash Sharma7 Jul '08 - 2:18 
GeneralRe: Some problems Pinmembersanzopaol9 Feb '11 - 7:51 
GeneralRe-loading the report data to the ReportViewer PinmemberAlec MacLean7 Mar '08 - 6:10 
Hi,
Great article, which has helped tremendously. I did have a problem though, which was a simple fix, if not terribly obvious.
 
I thought it might help anyone else out there using the same technique as me if I posted my approach. (I'm using VB, not C#, but code should be easy to follow.)
 
I have the ReportViewer on a winform, which also has a customer list (a Combobox) and two date fields that provide from-to values (both DateTimePickers). These supply the parameters to a web service, which calls a stored procedure with the supplied parameters and returns a dataset with the report result values.
 
On first running the report, this works exactly as expected.
 
My issue was that on re-running the report - even without changing the parameter values - the report wasn't updating to reflect the new values.
 
Fortunately the fix was simply calling the "Reset" of the ReportViewer before binding it.
 
My code goes like this:
 

Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerate.Click
Try
'Get the data matching user-specified criteria (date range/customer).
Me.LoadInvoiceReportDataset()
 
'Reset the ReportViewer. Required if performing subsequent report calls.
Me.rvInvoice.Reset()
 
'Set processing mode, report definition file, etc.
Me.SetReportProperties()
 
'Refresh the report content
Me.rvInvoice.RefreshReport()
 
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
 
End Sub
 

Private Sub LoadInvoiceReportDataset()
Try
'Call web service to obtain report dataset.
Me.dsReport = serviceProxy.Finance_PhysioCustomer_Report_Select(CInt(Me.cbxCustomer.SelectedValue), Me.dtpFrom.Value, Me.dtpTo.Value)
 
''####################################################################################
''These steps are only required if the report structure changes and is intended
''for designer use only. Not required for production run-time.
''To create a representation of the report data fields, we create an XSD file
''from the dataset, then manually add it to the project so it shows up in the
''DataSources explorer.
'Me.dsReport.DataSetName = "InvRep"
''Create XML schema for the data
'Dim xw As System.Xml.XmlWriter
'xw = System.Xml.XmlWriter.Create(My.Application.Info.DirectoryPath + "\InvRep.xsd")
'Me.dsReport.WriteXmlSchema(xw)
''When running VS in debug mode, the XSD will appear in the \bin\debug folder.
''Import the new XSD as an "existing file" to the project.
''####################################################################################
 
Catch ex As Exception
MessageBox.Show("Error obtaining report data" & vbCrLf & ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
 
Private Sub SetReportProperties()
'Set properties for the report viewer.
Try
'The path to the RDLC (report layout and binding description). This is
'set to be copied locally with the app (ClickOnce required), so we can use
'the app run location as the path.
Me.rvInvoice.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Local
Me.rvInvoice.LocalReport.ReportPath = My.Application.Info.DirectoryPath + "\reportInvoiceSummary.rdlc"
Me.rvInvoice.LocalReport.ExecuteReportInCurrentAppDomain( _
System.Reflection.Assembly.GetExecutingAssembly.Evidence)
 
'Bind the report to the viewer
Dim rdsRpt As ReportDataSource
rdsRpt = New ReportDataSource("InvRep_InvoiceReport", Me.dsReport.Tables("InvoiceReport"))
Me.rvInvoice.LocalReport.DataSources.Add(rdsRpt)
 
Catch ex As Exception
MessageBox.Show("Error setting Report viewer properties" & vbCrLf & ex.Message, _
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
 
End Sub

 
Hope that helps someone!
 
Alec
QuestionHow to fill dataset derived from XSD file? PinmemberColizobble9 Oct '07 - 1:29 
Thanks very much for your article. I would like to use the approach you outline, but I'm having a problem with filling the dataset.
 
I have created the XSD file and I've used ReadXMLSchema to set up the dataset definition. I understand how to bind a filled data table at runtime to the report. How do I fill the data table though? I cannot use ReadXML because my data is in SQLServer2000.
 
Examining the XSD file, I can see that it contains all the SQL information I need (query text, parameters etc) and I know VS can create its strongly-typed datasets based on this info. But short of directly parsing the XSD file, I don't see any methods that the DataSet class provides to create the adapter I need to fill the dataset. I tried using CreateDataReader but that doesn't work.
 
Can you offer any advice? I notice in your article, you seem to skip over this aspect.
AnswerRe: How to fill dataset derived from XSD file? PinmemberDIren9 Oct '07 - 3:07 
GeneralRe: How to fill dataset derived from XSD file? PinmemberColizobble9 Oct '07 - 3:34 
Question3d charts in rdlc files Pinmemberkriskan4 Sep '07 - 18:48 
I have to use rdlc files and wanna show 3d charts can any one help me
 
kriskan

AnswerRe: 3d charts in rdlc files PinmemberDIren5 Sep '07 - 1:45 
GeneralTransform DataSet Xml Schema to RDLC Pinmembernbohr99a16 Aug '07 - 15:33 
The easiest way to generate a simple RDLC from a dataset is transform the schema xml into the RDLC.
 
The basic idea is to build rather generic RLDC file off a DataSet. You can then bind both the DataSet and the RDLC to a ReportViewer control and get your report. I generate the RDLC by transforming the DataSet XML schema into a RDLC file via and XSLT transform.
 
Here is a website showing the C# code and the XSLT...
 
http://csharpshooter.blogspot.com/2007/08/revised-dynamic-rdlc-generation.html
QuestionHow to bind data source in rdlc Pinmemberimran_Shaikh4 Jul '07 - 6:24 
Confused | :confused: i want make an rdlc report in which i want all object
make in run time.
simple i want make an rdlc report in which data field must
be creat in run time,

AnswerRe: How to bind data source in rdlc PinmemberDIren5 Jul '07 - 2:00 
QuestionNot Working................... [modified] Pinmemberallanace85226 Jun '07 - 1:23 
i've tried the logic but still i'm receiving some errors here my codes :
 
Report1.rdlc ---------->
 
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
   <BottomMargin>1in</BottomMargin>
   <RightMargin>1in</RightMargin>
   <rd:DrawGrid>true</rd:DrawGrid>
   <InteractiveWidth>8.5in</InteractiveWidth>
   <rd:SnapToGrid>true</rd:SnapToGrid>
   <Body>
      <ReportItems>
         <List Name="list1">
            <Left>0.5in</Left>
            <ReportItems>
               <Textbox Name="textbox1">
                  <rd:DefaultName>textbox1</rd:DefaultName>
                  <Width>1.5in</Width>
                  <Style>
                     <PaddingLeft>2pt</PaddingLeft>
                     <PaddingBottom>2pt</PaddingBottom>
                     <PaddingRight>2pt</PaddingRight>
                     <PaddingTop>2pt</PaddingTop>
                  </Style>
                  <CanGrow>true</CanGrow>
                  <Height>0.25in</Height>
                  <Value>=Fields!pcode.Value</Value>
               </Textbox>
            </ReportItems>
            <DataSetName>DataSet1_DataTable1</DataSetName>
            <Top>0.25in</Top>
            <Width>3.5in</Width>
            <Height>1in</Height>
         </List>
      </ReportItems>
      <Height>2in</Height>
   </Body>
   <rd:ReportID>2ec40e93-afa1-4fc5-8ff3-a2fb87b83521</rd:ReportID>
   <LeftMargin>1in</LeftMargin>
   <Width>6.5in</Width>
   <InteractiveHeight>11in</InteractiveHeight>
   <Language>en-US</Language>
   <TopMargin>1in</TopMargin>
</Report>
 
------------------------------------------
 
my C# codes------------------------------->
        
private void LoadDataToReport()
            {
           
                  string connectionString = "Data Source=localhost;" +
                  "Initial Catalog=ibidentrial;User=root";
 
                  string SQL = "SELECT * FROM emp";
                  MySqlConnection con = new MySqlConnection(connectionString);
                  MySqlCommand com = new MySqlCommand(SQL, con);
                  MySqlDataAdapter adapter = new MySqlDataAdapter(com);
                  DataSet ds = new DataSet();
                 
                  try
                  {
                        con.Open();
                        adapter.FillSchema(ds, SchemaType.Mapped, "DataTable1");
                        adapter.Fill(ds, "DataTable1");
                  }
                  catch (Exception err)
                  {
                        Console.WriteLine(err.ToString());
                  }
                  finally
                  {
                        con.Close();
                  }
 
                  ds.DataSetName = "DataSet1";
                  ds.WriteXmlSchema("c:\\testing1.xsd");
                  ds.WriteXml("c:\\testing1.xml");
 
                  ds.ReadXmlSchema("c:\\testing1.xsd");
                  ds.ReadXml("c:\\testing1.xml");
 

                  reportViewer1.ProcessingMode = ProcessingMode.Local;
                 
                  reportViewer1.LocalReport.DataSources.Add(new   ReportDataSource("DataSet1_DataTable1", ds.Tables[0]));
reportViewer1.LocalReport.ReportPath = "C:\\Report1.rdlc";
                  reportViewer1.RefreshReport();
 

 
            }
 
error receive :
The list 'list1' is in the report body but the report has no dataset. Data Regions are not allowed in reports without datasets.
 
what seems to be the problem of my codes?did i miss something or what?..... please help i need it very badly............... im just using c# express edition and i used the vwd express edition to design the Report.rdlc ........
tnx
 

 

 
-- modified at 7:49 Tuesday 26th June, 2007
Questiondataset XML from pivoted table Pinmemberajbarton197221 Jun '07 - 7:03 
Hello,
The dataset I'm using gets fed its data after applying a pivot to the data returned from a SQL query (i.e. The rows returned in the query become the columns in the report) As a result, I don't know how many columns will be in the report until runtime, so I need to generate both my RDLC and dataset at runtime. I can create a sample dataset to generate a schema, but it will likely have the wrong number of columns when it comes to the final report.
Do you have any idea how to handle this situation?
The column names and data are bound to a field in the dataset. The problem I'm seeing is in the changing quantity of columns.
 
Thank you for any help you can provide.
 
Tony Barton.

AnswerRe: dataset XML from pivoted table PinmemberDIren22 Jun '07 - 3:32 
QuestionRDLC Generator PinmemberSu_shamim23 May '07 - 20:42 
I want to Generate rdlc & rdlc data source from by object collection at runtime. How can I do that?
AnswerRe: RDLC Generator PinmemberDIren17 Jun '07 - 21:12 
GeneralSaving report to the file [modified] Pinmembermishasoft12 May '07 - 9:38 
Hey.
Ok, I'v got the report and I can see that.
Is there any way to save the reportView to the file?
I would like to save it to the Word (DOC) file, but failed to find the way to do that.
Is it possible?

 

 
Best regards,
Michael Gershkovich
GeneralRe: Saving report to the file PinmemberDIren17 Jun '07 - 20:50 
GeneralNewbie in Reportviewer Pinmembercocoonwls19 Apr '07 - 20:24 
Hi DIren,
 
I am according the step you are list in the article, but i am facing a problem. That is i don't know what the mean by "Load the schema" and how to do it. Can you list in details how to generate report at runtime or direct me to any tutorial or any related sources?
 
thanks in advance
cocoonwls
GeneralRe: Newbie in Reportviewer PinmemberDIren22 Apr '07 - 23:40 
GeneralRe: Newbie in Reportviewer Pinmembercocoonwls25 Apr '07 - 6:04 
GeneralBest Article Ever! Pinmemberharindaka17 Apr '07 - 23:41 
This is no doubt one of the most useful articles on codeproject. I used to do the same thing using crystal reports a few years back but had problems with the MS reportviewer version because i was completely new to it. This solved most of my problems. Would u believe it took me almost a day to get it working! Alls well that ends well. Thanks Man!
GeneralRe: Best Article Ever! PinmemberDIren18 Apr '07 - 1:40 
GeneralReport Pinmembermadhuri.hyd@cnkonline.com9 Apr '07 - 23:38 
Hi,
I am working on reports in vs 2005.
I am using charts,reports are coming but all graph lines are in equal highet.
 

 
madhuri
GeneralRe: Report PinmemberDIren18 Apr '07 - 1:38 
GeneralTake a long time for report Loading PinmemberArek Suroboyo21 Mar '07 - 19:38 
I am a newbie in Reporting Services. I am trying to load rdlc programmatically combine with xml and xsd files. I used 2 interfaces. first, with Tabcontrols (just click a bottom and a report viewer will load my reports on another tab) and the second with open a new form.
 
with new form, I can generate and load a report in a few seconds. but, it doesn't work with tabcontrols, it takes a long time to load it.
 
////////////////////////////////////////////////
Here is the list part from new form interface
 
private void button9_Click(object sender, EventArgs e)
{
bool ret = getReportDataSet(ref dsReport, dataSetName, dataTableName);
string reportSourceFile = getProjectSourcePath() + @"\Retail System.rdlc";
 
frmReportView f = new frmReportView();
f.repView.Reset();
f.FormCaption = "Test Reports";
f.ReportDisplayName = "Reports";
f.repView.LocalReport.ReportPath = reportSourceFile;
ReportDataSource reportDataSource = new ReportDataSource(dataSetName + "_" + dataTableName, dsReport.Tables[0]);
f.repView.LocalReport.DataSources.Add(reportDataSource);
f.repView.RefreshReport();
f.Show();
}
 
private void frmReportView_Load(object sender, EventArgs e)
{
this.Text = this.FormCaption;
LocalReport l = repView.LocalReport;
l.DisplayName = this.ReportDisplayName;
//this.repView.ShowToolBar = false;
 
this.repView.DocumentMapCollapsed = true;

totalPages = this.repView.LocalReport.GetTotalPages();

 
reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PrinterSettings = new PrinterSettings();
pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
pageSetupDialog.PageSettings = new PageSettings();
pageSetupDialog.PageSettings = pageSettings;
 
pageSetupDialog.PageSettings.Margins = repView.LocalReport.GetDefaultPageSettings().Margins;
pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;
 
this.repView.RefreshReport();
}
 

And here is for tabcontrols interface
/////////////////////////////////////////
private void button5_Click(object sender, EventArgs e)
{

bool ret = getReportDataSet(ref dsReport, dataSetName, dataTableName);
string reportSourceFile = getProjectSourcePath() + @"\Report1.rdlc";
 
repView.Reset();
FormCaption = "Test Report";
ReportDisplayName = "Test";
repView.ProcessingMode = ProcessingMode.Local;
repView.LocalReport.ReportPath = reportSourceFile;
ReportDataSource reportDataSource = new ReportDataSource(dataSetName + "_" + dataTableName, dsReport.Tables[0]);
repView.LocalReport.DataSources.Add(reportDataSource);
repView.RefreshReport();
this.LoadReport();
this.repView.Show();
MessageBox.Show("Done", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
 
private bool LoadReport()
{
this.Text = this.FormCaption;
LocalReport l = repView.LocalReport;
l.DisplayName = this.ReportDisplayName;
//this.repView.ShowToolBar = false;
 
this.repView.DocumentMapCollapsed = true;
 
totalPages = this.repView.LocalReport.GetTotalPages();
 

reportPageSettings = repView.LocalReport.GetDefaultPageSettings();
pageSetupDialog = new PageSetupDialog();
pageSetupDialog.PrinterSettings = new PrinterSettings();
pageSettings = new PageSettings(pageSetupDialog.PrinterSettings);
pageSetupDialog.PageSettings = new PageSettings();
pageSetupDialog.PageSettings = pageSettings;
 
pageSetupDialog.PageSettings.Margins = repView.LocalReport.GetDefaultPageSettings().Margins;
pageSetupDialog.PageSettings.PaperSize = repView.LocalReport.GetDefaultPageSettings().PaperSize;
 
this.repView.RefreshReport();
return true;
}
 

Could you help me to solve this problem ??
 
thx

GeneralRe: Take a long time for report Loading PinmemberDIren22 Mar '07 - 3:44 
GeneralRe: Take a long time for report Loading PinmemberDjallaDK20 Oct '07 - 11:47 
GeneralOnline Reporting PinmemberSarfaraj Ahmed17 Feb '07 - 3:39 
Actually Im doing some online Reporting and the Database is in the Server so How can I create StoredProcedure on the otherhand I am going to Create another website to get the Online Report from the Server DataBase. So wot do you suggest? and what should I use?
 
Can I use Microsoft REPORT.rdlc which is in VS 2005? If yes how can I do it without Stored Procedure. And how can I pass data to one page to another page. I have already read about drillthrough reporting which is in CodeProject. Any website recommended or any source code or any project with VB
 
Thanks
 
Sarfarj Ahmed

GeneralRe: Online Reporting Pinmembermnphillips11 Sep '12 - 3:47 
GeneralReport.rdlc problem PinmemberSarfaraj Ahmed6 Feb '07 - 7:08 
Hi EveryBody
Im using ASP.NET with VS 2005 and trying to make report with Microsoft Reporting Service. Those error Im getting is follows.
 
1.Report Viewer cant change the report. Example I got a TextBox under a Button where I can put a CustomerID in TextBox. I have put a CustomerID 1001 inside the TextBox and Clicked the Button, 1st Time Im getting the whole informations about that particular Customer. When I have changed the CustomerID like 1002 then !!! inside the code is working properly and the DataSet shows the information about that CustomerID 1002 but ReportViewer cant change the Customer Informations its remain same. Still its showing 1001 informations.
 
2.A data source instance has not been supplied for the data source 'DataSetAUDITLOG_CountLessons'. I have created 2 tables inside the DataSetAUDITLOG after that I have deleted CountLessons table from DataSET and Im not using this Table anymore and there is no relation with table anywhere. So why Im getting this error.
 
3. On the otherhand I want to send a CustomerID value to another page from a ReportViewer. Could you please tell me. How can I do it? If you have any project example about this please send me.
 
I need your help
Thanks
 

 
Sarfarj Ahmed

GeneralRe: Report.rdlc problem PinmemberDIren8 Feb '07 - 2:10 
GeneralRe: Report.rdlc problem PinmemberSarfaraj Ahmed12 Feb '07 - 0:46 
GeneralRe: Report.rdlc problem PinmemberDIren15 Feb '07 - 21:24 
GeneralRe: Report.rdlc problem PinmemberMikeTokar12 Jun '07 - 21:32 
QuestionNot working fo rme. PinmemberBKunneke18 Jan '07 - 3:54 
I get a compile error when I try to Add the datasource to the local report. The error states that there isn't a signature for the Add method that accepts 2 parameters. When I change it to 1 parameter (just the DataTable), I get an error that it can't convert the DataTable to a ReportingDataSource.
 
Your article is laid out well, it definitely addresses the same scenario I'm trying to accomplish here, but I keep running into problems making the report run dynamically at run time. Any help or ideas are appreciated.

 
BK
AnswerRe: Not working fo rme. PinmemberDIren8 Feb '07 - 1:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 25 Jul 2006
Article Copyright 2006 by DIren
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid