Friday, March 23, 2012

Report Viewer

Hi,

I am new to using Report Viewer.

I created a basic report (Local Mode) using Report vIewr control in VS 2005 and typed dataset and it works fine.

But I would like to view a report with a parameter.

Can anyone explain me how to do that and bind it with the report viewer?

Thanks & Regards,

Lavanya.

Do you want to set parameters from your code?

|||

In the ASPX right after the

see the object source code and replace with your stuff

<asp:ObjectDataSourceID="ObjectDataSource2"runat="server"

SelectMethod="GetData"

TypeName="DataSetOTDTableAdapters.DataTableOTDFamilyTableAdapter">

<selectparameters>

<asp:querystringparametername="FromDate"querystringfield="FromDate"defaultvalue="01/01/2007"/>

<asp:querystringparametername="ToDate"querystringfield="ToDate"defaultvalue="07/01/2007"/>

</selectparameters>

</asp:ObjectDataSource>

that coresponds to a getdate method in the dataset that has 2 parameters @.FromDate and @.ToDate

You can also change the values of parameters in the PageInit event.

|||

I want to set the parameters in the report.rdlc.

I got one parameter working.

I have two textboxes. I have to see the report for a specific date range.

How can I do that?

For a single date, I set the operator in the filter as =.

What if I want to use two parameters (date range).

How do I set it in report.rdlc?

|||

I am assuming you are not using Crystal Reports. How do you fill the dataset? Can you supply the range parameters to the dataset instead of reportviewer? Also see if filtering works for you:

http://msdn2.microsoft.com/en-us/library/ms252125(VS.80).aspx

As I suggested, filtering data before report is rendered is a better option.

|||

Hi, I have a matrix report with rows as a name and the column as a date field.

When i run the report it works the way i want.

08/03/2007 07/31/200708/01/2007Adams , William484Anderson , David480Asseng , Steve440Bangerd , Michael048Barnaskas , Joe000Barry , Timothy084Berry , Jerry404Bowen , Nels000Breakall , Jeff4012Brockel , Robert048Campbell , Bryan000Castro , Carlos000Childs , Michael8124Conklin , Terry888

But when I give the parameter as the date(08/03/2007), I am not gettin the rows with 0. What am i doin wrong?

|||

Are you doing the filtering as suggested in that article?

|||

Yeah I create report parameters and then I include filters in the matrix.

|||

Am just curious, 0 implies there is no record or value for that date, right? So that means filter works as it should. Or, what do those values mean?

|||

Yeah... 0 means the count of the entries for that date is 0. If it is 4 it means the count of entries for that date and for that tech is 4.

Now when i dont include any parameters, I get the 0 entries also.

I need the same thing when i include my date parameter.. is it possible?

|||

I am sorry but maybe I am not getting it right. What is the purpose of a filter if you want to display all the values. Let me look into it and I will get back to you if I find something.

|||

It is just similar to the one without parameter. I add an parameter So that I can see the data only for that date. Now it is shoeing all dates...

|||

Lets backtrack. Is filtering working for you or not?

|||

Yeah it works. But the problem is it doesn not show me the columns with 0 .

|||

Let me put it crisp.

What I am trying to do is a Compliance report. If the tech comes in for that day he is compliant, if not he is not compliant.

So what I did was I did a matrix report with rows as Technician Name , Columns as Date and data as Count(Date)

It worked perfect. The result is shown below.

07/31/200708/01/200708/02/2007Adams , William848Anderson , David804Asseng , Steve404Bangerd , Michael488Barnaskas , Joe000Barry , Timothy844Berry , Jerry044Bowen , Nels000Breakall , Jeff0124Brockel , Robert4812Campbell , Bryan000Castro , Carlos000Childs , Michael1244Conklin , Terry888Contractor , Contractor000Cooke , Jackie000DeLeon , Carlos8120Dorn , Craig400Ehrlich , Chase000Elswick , James000English , Mike400Ewing , David000Favalora , Anthony41212Fierke , Bruce000Figueroa , Richard000

Now I need to include parameter to show the report for a specific date. In our example let us take 7/31/2007

I included report parameters for the report and filters for the matrix where Fields!Date.Value=Parameter!Date.Value

I have a textbox and a button in my aspx page.

On button click

Dim pubAs Microsoft.Reporting.WebForms.ReportParameter

Dim pubdateAsString = TextBox1.Text

pub =New Microsoft.Reporting.WebForms.ReportParameter("Arrival_Time", pubdate)Me.ReportViewer1.LocalReport.SetParameters(New Microsoft.Reporting.WebForms.ReportParameter() {pub})

ReportViewer1.LocalReport.Refresh()

And then I run the report with 07/31/2007 in the textbox and hit the button. I dont get

Barnaskas , Joe

Berry , Jerry

Bowen , Nels

Breakall , Jeff

Campbell , Bryan

Castro , Carlos

Contractor , Contractor

Cooke , Jackie

Ehrlich , Chase

Elswick , James

etc..,

because the count is 0.

Hope I explained it at my best. Please help.

No comments:

Post a Comment