Showing posts with label reportviewer. Show all posts
Showing posts with label reportviewer. Show all posts

Thursday, March 8, 2012

Data Binding with ReportViewer Control to an Independent Data Table

Here is what I am trying to do. I am using ASP.NET 2.0. I have created a data set called Stocks data table called Data and put it in the App_Code folder. I am filling the data table from data in a csv file located on the web. I am populating the data table with the following code. This code works because I checked the record count and it shows 21 records for the Data data table.

publicstaticDataSet Convert() { WebClient Client =newWebClient(); Stream myStream = Client.OpenRead("http://mysite.com/table.csv"); StreamReader myStreamReader =newStreamReader(myStream); Stocks myStocks =newStocks(); string line = myStreamReader.ReadLine(); string allData = myStreamReader.ReadToEnd(); string[] rows = allData.Split("\r\n".ToCharArray()); foreach (string rin rows) { string[] items = r.Split(",".ToCharArray()); myStocks.Tables["Data"].Rows.Add(items); } return myStocks; }

I am trying to bind the data in this table to a report. I added a report to my project and selected the fields from the data table. I then added a ReportViewer control to the web form. I'm not sure how to configure the ObjectDataSource that is added to the web form after the ReportViewer control is added. It firsts asks to select business object. I have the following options. I'm not sure what to select.

Stocks

Stocks + DataTable

Stocks + DataRow

Stocks + DataRowChangeEvent

Stocks + DataRowChangeEventHandler

Next I need to define a data method. Not sure what option to select. I just want to bind the report to the data table and return the rows.

Any help would be appreciated. Thanks.

Weste

Once you drag and drop the report viewer in the aspx page, you will get a smart tag next to your report viewe. From that select the repot.rdlc.

Itr will automatically configure the object datasorce for you.

Did you design your report.rdlc using the dataset you created?

|||

Yes, that is what I already tried and it didn't work. It didn't configure the datasource correctly. I received the following error.

An error has occurred during report processing.
The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found.

This is the code that was automatically added after I added the ReportViewer

<asp:ObjectDataSourceID="ObjectDataSource1"runat="server"SelectMethod="GetData"

TypeName="StcoksTableAdapters."></asp:ObjectDataSource>

I'm not sure how to configure the ObjectDataSource that is added to the web form after the ReportViewer control is added. It firsts asks to select business object. I have the following options. I'm not sure what to select.

Stocks

Stocks + DataTable

Stocks + DataRow

Stocks + DataRowChangeEvent

Stocks + DataRowChangeEventHandler

It then asks me to choose a method. Some of the available options are

Clone(), returns DataSet
Copy(), returns DataSet
CreateDataReader(), returns DataTableReader

I have done other reports using a SQL datasource and they work fine. It works somewhat different without a SQL datasource. I am having trouble finding any documentation to assist me. Thanks for your help.

Weste

|||

I resolved the issue. I added a class called StockData. I moved the code for the Convert procedure into this class. I then configured the ObjectDataSource as follows:

Business Object: StockData
Select Method: Convert(), returns DataSet

Tuesday, February 14, 2012

Customizing the Reporting Services UI

I want to make custom changes to the Report Manager and ReportViewer (i.e.
background color, adding the customers logo, etc.). Where are the UI for
these reporting UI located.
If its not advisible to change them, I want to clone them and make my own
customized UI.On Aug 1, 1:56 pm, Mike Johnson <Mike
John...@.discussions.microsoft.com> wrote:
> I want to make custom changes to the Report Manager and ReportViewer (i.e.
> background color, adding the customers logo, etc.). Where are the UI for
> these reporting UI located.
> If its not advisible to change them, I want to clone them and make my own
> customized UI.
For the Report Manager, this link may be of assistance.
http://msdn2.microsoft.com/en-us/library/ms345247.aspx
Hope this helps.
Regards,
Enrique Martinez
Sr. Software Consultant