Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Reporting Services / June 2008

Tip: Looking for answers? Try searching our database.

ReportViewer - how to fill a text box from data on the parent form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dbuchanan - 12 Jun 2008 06:06 GMT
I have a report with a data region (table or matrix) that is filled from a
dataset.

The menu that supplies the parameters for the report's dataset resides on
the web page on whch the ReportViewer is placed. During the criteria
selection I build a textual descripton of the selections mand by the user.
This is to appear on the face of the report. I assume I must create a
tableadapterr in the  dataset into which I must somhow send the text data
from the form, But how do I do this. Or is there a simpler way.

Please explain how,

Thank you,
Doug
Charles Wang [MSFT] - 12 Jun 2008 10:12 GMT
Hi Doug,
Did you mean that you would like to display the user criteria selection in
text on the fact of your report once it is made by the user?
If I have misunderstood, please let me know.

You can work around this issue by using a report parameter. If you are
developing a web application, you can first save the user criteria
selection in a session variable. Every time you make a criteria selection,
first read the former selection from the session and then combine the
current selection with the former selections and save it to the session,
and then set the new value for your report parameter and refresh your
report in your reportviewer. If you are using a WinForm application, you
can save the selections to a static variable or global variable.

In your report, you need to drag a TextBox to the place where you want to
display the criteria selection on your report, create a report parameter
named "SelectionCriteria" and set the value to
"=Parameters!SelectionCriteria.Value".

For example:
===================================================
// Once you select a criteria, save it to a session variable
If(Session["SelectionCriteria"]!=null)
  Session["SelectionCriteria"] += <your selection text>
else
   Session["SelectionCriteria"] = <your selection text>

reportViewer1.ProcessingMode = ProcessingMode.Remote;

  // Set report server and report path
  reportViewer1.ServerReport.ReportServerUrl = new
     Uri("http://localhost/reportserver");

  reportViewer1.ServerReport.ReportPath =
     "/AdventureWorks Sample Reports/Employee Sales Summary";

  List<ReportParameter> paramList = new List<ReportParameter>();

  paramList.Add(new ReportParameter("SelectionCriteria",
Session["SelectionCriteria"].ToString(), false));

//set the value of the selection items to other parameters
......

  this.reportViewer1.ServerReport.SetParameters(paramList);

  // Process and render the report
  reportViewer1.RefreshReport();
=====================================================

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for
non-urgent issues where an initial response from the community
or a Microsoft Support Engineer within 1 business day is acceptable.
Please note that each follow up response may take approximately
2 business days as the support professional working with you may
need further investigation to reach the most efficient resolution.
The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
============================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
dbuchanan - 21 Jun 2008 06:24 GMT
Charles,

First I am using ReportViewer in local mode. This is new to me so there are
large shares that I do not understand. I will place my questions and
comments below in the areas where I need clarificaton. I will remove
sections that do not apply.

> Did you mean that you would like to display the user criteria selection in
> text on the fact of your report once it is made by the user?
> If I have misunderstood, please let me know.

Yes I want to dispaly user criteria selection in a text box on the face of
the report.

> You can work around this issue by using a report parameter.

What is a report parameter?

> If you are
> developing a web application, you can first save the user criteria
> selection in a session variable.

I am currently storing it in a hidden unbound list box so that I can remove
a line for each step backwards if the user backs up through the menu to make
a change. At the render report button I would pull out the contents to a
session variable ~ I guess.

> Every time you make a criteria selection,
> first read the former selection from the session and then combine the
> current selection with the former selections and save it to the session,

I will do this as described above.

> and then set the new value for your report parameter and refresh your
> report in your reportviewer.

I am using a multi view which will not expose the ReportViewer until all the
criteria is selected and the user clicks a button.
Explain aobut the report paramter, what it is and seeting values to it. (I
am using local mode).

> In your report, you need to drag a TextBox to the place where you want to
> display the criteria selection on your report, create a report parameter
> named "SelectionCriteria" and set the value to
> "=Parameters!SelectionCriteria.Value".

How do I create a report parameter? Is that a data control? I don't see it.

> For example:
> ===================================================
[quoted text clipped - 5 lines]
>
> reportViewer1.ProcessingMode = ProcessingMode.Remote;

I am using ProcessingMode.Local. Does andy of this change?

>   List<ReportParameter> paramList = new List<ReportParameter>();
>
[quoted text clipped - 8 lines]
>   // Process and render the report
>   reportViewer1.RefreshReport();

Please explain the above lines. All of them.

Thank you,
Doug
Charles Wang [MSFT] - 24 Jun 2008 12:48 GMT
Hi Doug,
My above code is for server report. I had thought that you were using a
server report. Anyway for creating a report parameter in a local report,
you can first open your local report, click Report menu at the top of the
menu bar, click "Report Parameters...", click Add to add a parameter which
name is assumed to be "CRETERIA",  select the Data type as String, check
Allow blank value, input a space to the Default values and then click OK.

After that you can drag a textbox to your report and set the value to
"=Parameters!CRETERIA.Value". Then in your web page, you can write your
code like the following when you add a criteria:
=============================================================
       //add a new creteria
       strCreteria += strNewCreteria;

       // set the report parameter
       List<ReportParameter> paramList = new List<ReportParameter>();
       paramList.Add(new ReportParameter("CRETERIA",strCreteria));
       this.ReportViewer1.LocalReport.SetParameters(paramList);

       //render the report
       this.ReportViewer1.LocalReport.Refresh();
=============================================================

Hope this helps. If you have any other questions or concerns, please feel
free to let me know.

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
dbuchanan - 25 Jun 2008 06:20 GMT
Charles,

In my effort to populate the text box in the report I am using StringBulder
to collect text entered in a ListBox.

Remainder & background: The reason I used the list box was so that I could
remove as well as add data in the event the user chose to go back to a
previous menu in the MultiView.

I am using the following code to retreave the data from the ListBox:

   private void RecordGetCriteriaDescription()
   {
       StringBuilder sb = new StringBuilder("Descripton of the Criteria:");

       foreach (ListItem li in lst0Selections.Items)
       {
           sb.AppendLine(li.Value.ToString());
       }
       CriteriaDescriptionLabel.Text = sb.ToString();
   }

What I am receiving in the intermediate label is run-on text rather than new
lines for each entry.

How can I resolve this?

Thanks,
Doug
Charles Wang [MSFT] - 26 Jun 2008 09:13 GMT
Hi Doug,
If CriteriaDescriptionLabel is a web control, please append "<br>" to the
end of each item:
sb.AppendLine(li.Value.ToString()+"<br>");

If you want to display the criteria in your report, you need to replace
"<br>" by "\r\n".

Hope this helps. Please feel free to let me know if you have any other
questions or concerns.

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
dbuchanan - 27 Jun 2008 05:16 GMT
Charles,
Thank you for your reply.
As it ultimately worked out once I was able to construct the parameter -
even though the carrage returns did not render correcty in the label on the
form and even though I did not use "\n" they actually rendered correctly in
the report itself. (?!)
Thanks.
Doug
Charles Wang [MSFT] - 27 Jun 2008 08:02 GMT
Hi Doug,
Thank you for your response.

Anyway it is good to see that you figured your problem out. Congratulations!

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
dbuchanan - 26 Jun 2008 09:44 GMT
Charles,

>        // set the report parameter
>        List<ReportParameter> paramList = new List<ReportParameter>();
>        paramList.Add(new ReportParameter("CRETERIA",strCreteria));
>        this.ReportViewer1.LocalReport.SetParameters(paramList);

What you had would not work,but I found this to be helpful which you
supplied to someone in May

           ReportParameter p = new
ReportParameter("year",this.txtProductKey.Text);
           this.reportViewer1.ServerReport.SetParameters(new
ReportParameter[] { p });

Thanks,
Doug
Charles Wang [MSFT] - 26 Jun 2008 10:59 GMT
Hi Doug,
There must be something different between our codes. Per my test, it worked
fine. Actually there is no much difference between a generic list and a
normal array here. They should be both working. May you elaborate the not
working scenario?

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
dbuchanan - 27 Jun 2008 05:23 GMT
Charles,

I have no explaination. It may have to do with the using statements, but
your fist code, except for the first line was totally unrecognized by
intellisense in Visual Web Developer 2005 77626-009-0000007-41465 (Visual
Studio 2005 )

Here are my using statements:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Text;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Reporting.WebForms;

The main point is that your May code to another user did work

Thanks,
Doug
Charles Wang [MSFT] - 27 Jun 2008 08:07 GMT
Hi Doug,
Thank you for your response.

Yes, you got the point. If the namespace "System.Collections.Generic" was
referenced, it would work at your side. Sorry for not mentioning it
earlier. I had thought that you knew it.

If you have any other questions or concerns, please feel free to let me
know. Have a nice day!

Best regards,
Charles Wang
Microsoft Online Community Support
=========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@microsoft.com.
=========================================================
Signature

This posting is provided "AS IS" with no warranties, and confers no rights.

=========================================================
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.