Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass set af params using paramenter obj C# 1

Status
Not open for further replies.

theogary

Programmer
Mar 3, 2003
99
US
I want to pass three parameters to a report services report in .net. I want to put the parameters in parameter object. Then set the parameter object to the report dynamically.
 
Did you have a question or were you just going to let us know what you're working on? ;)
 
I am a newbie , so I wanted a some sample code on how to do this.
 
You need to pass the parameters in the URL string used to load the report.

[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
I do not want to use query string. I want use Server.Transfer("~/Reports/Rpt.aspx") and the access the parameter variable on the prior page and assign it to the report in the rpt.aspx page...
 
Store the parameters in textboxes. You can then access them after you do the transfer.
 
I am creating a reusable object. I would like to pass the parameterObject as a variable. is this possible.....
 
you need to do some basic research on HTML Forms and Post/Get commands this is the cornerstone for all web development. once you understand this, then you need to understand how asp.net mucks up this up with the page life cycle. then you can choose a solution which best meets your requirments.

right now it's like throwing darts in the dark hoping you land on the bulls eyes.

Also when requesting help, be sure to
1. clearly ask a question
2. include all the requirements and constraints
3. post your current code working or not


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
protected void Button1_Click(object sender, EventArgs e)
{
ParameterCollection PC = new ParameterCollection();
Parameter par = new Parameter();
par.Name = "zip_code";
par.DefaultValue = "11372";
PC.Add(par);
string returnUrl = "~/Reports/Rpt.aspx";
Response.Redirect(returnUrl);
Server.Transfer("~/Reports/Rpt.aspx");
}

here is my code... I want Rpt.aspx to pickup the PC variable on the other end. I thought this was a simple and common thing to do. If this approach is impossible I will try something else. This reusable page have several different user controls(list of reports) the user can pick from, each report will gathering various parameters. I thought if you could package all you arguments into on parameterCollection variable, you could just attach this variable to the corresponding report on the next page.
 
Usually it is sent over in the query string.

Or you can put it into a Session Variable.

Just TWO of the many things you could do.
 
If the target is an asp.net page then you should be able to get it working using the advice given, but it'll take some doing in the page load event (where you'll have to build a query string to load it in hte report viewer anyway). If its' an SSRS report, pretty sure you've got to use the query string.

Hope this helps,

Alex

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
parameter collection only exists within this function. so the minute you exit the function the variable doesn't exist. The same is true if you move the variable to the class. it will loose scope once you transfer away from the object (redirect or transfer).

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Thanks for posting the explanation on why the Parameter Collection won't work, jmeckley.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top