PLAN:
1. Drop a ReportViewerControl to your favourite webform
2. Drop a new DataSet in the project (DataSet1)
3. Create a DataTable in DataSet's XSD (DataSet1.xsd) which should define the structure of <Books.xml>
I created Table1 which defines 2 types. I guess 2 are enough!!
- Book_ID (of type System.Int32)
- Title (of type System.String)
4. Drop a new RDLC file to project.
You will notice the DataSet1 and DataTable1 being shown in "WebSite Data Sources"
+ DataSet1
- DataTable1
- Book_Id
- Title
5. Drop a table to it.
Drag and drop the Fields ( Fields!Book_ID.Value and Fields!Title.Value)
6. use the CODE LISTING 2 in Page_Load.
NOTE: Pay attention to this line:
Me.ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet1_DataTable1", Dt))
DataSet1_DataTable1 is the link to this hack. We are telling ReportViewer to bind this table "Dt" of ours (which you might have got from somewhere) to a dataset which is understood by RDLC.
Note: You do not have to chose this RDLC in "ReportViewer Tasks". Which means rsweb:ReportViewer component is free to chose it's local report in runtime. Check the neat rsweb:ReportViewer component in CODE LISTING 3.
Here is how it looks when you bind it in design mode. But these all we are doing in RUN TIME.
<
CODE LISTING 1: Books.Xml
[XML]
<?
<!
</
[\XML]
CODE LISTING 2:
Protected
ReportViewer1.ProcessingMode = ProcessingMode.Local
rep.ReportPath =
ds.ReadXml(HttpContext.Current.Request.MapPath(
Dt = ds.Tables(0)
CODE LISTING 3: Just for reference, how your aspx page's HTML should look like.(completly unneccesary)
<body>
Thanks a lot, After long time i found my solution.