在.rdl报表中定义了参数,如何在已经加入了ReportViewer控件的.aspx窗体中给参数赋值。只要对Reporting Server有点研究的朋友都来支持一

ToSchool 2004-11-22 03:53:14
我新建一个报表Report1.rdl,定义了一个参数@s_dept,其SQL语句为"select * from user where dept=@s_dept",然后新建一项目,新建一窗体webfrom1.aspx,把ReportViewer控件拖进去,设置其ServerUrl属性为"http://dong/reportserver",ReportPath属性为"/report1"。

像上面的设计时,在运行查看时,发现@s_dept这个变量就会现在在页面上,要求用户去录入,之后点击“查看报表”才能显示数据。可这不是我所要求的,我要实现的是:比如在一主窗体上有一“打印”按钮,点击它后,弹出上面的webfrom1.aspx,此时@s_dept的值是从该主窗体传入进去的,而不是像现在这样由用户去录入或选择,就是说不用显示出@s_dept这个变量的文本框,而是在webfrom1.aspx页面弹出时直接根据主窗体传入的值显示出数据。我想这代码应该写在webfrom1.aspx的Page_Load事件中,用Request来获得主窗体传入的@s_dept变量值,可如何传给ReportViewer控件,即让Report1.rdl得到这个值,从而抽取出数据来。
(注:一定在页面上不显示@s_dept变量的录入的文本框)

请各位多帮忙,多来支持。
...全文
271 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ToSchool 2004-12-01
  • 打赏
  • 举报
回复
请drk928(一起看斜阳)、lutao206(海口冰玲) 、 dragonforfly(飘零)三位到http://community.csdn.net/Expert/topic/3605/3605091.xml?temp=.6861231再次来领分。
ToSchool 2004-12-01
  • 打赏
  • 举报
回复
感谢各位的支持,尤其是 drk928(一起看斜阳)、lutao206(海口冰玲) 、 dragonforfly(飘零)三位的帮助,将另开此http://community.csdn.net/Expert/topic/3605/3605091.xml?temp=.6861231贴给分。
Alden 2004-11-25
  • 打赏
  • 举报
回复
这里有你要想知道的东西
http://www.cnblogs.com/zsww/archive/2004/06/02/12894.aspx?Pending=true#Post
lutao206 2004-11-25
  • 打赏
  • 举报
回复
*****************************************************************ReportViewer.cs
这是我在原例子添加了一个方法SetQueryParameter(),修改后请重新生成一次,再进行调用,否则一样找不到此方法:) , 请你细看,不明之处,可以继续留帖子。。。。

至少调用方法,你已基本理解:)
lutao206 2004-11-25
  • 打赏
  • 举报
回复
Reporting Server 的有一个服务器端控件,ReportViewer

不知你是否安装了例子?
********************************** 看来你没有学习过自定义控件,加强这方面的知识吧。
/*=====================================================================File: Viewer.cs
using System;
using System.ComponentModel;
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing.Design;
using System.Drawing;

namespace Microsoft.Samples.ReportingServices
{
public class ReportViewer : WebControl
{

#region Methods
/// <summary>
/// Add or remove url access string properties.
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
private void SetParameter(string name, string value)
{
try
{
// Remove if value is null or empty. Value is null of the property grid value
// is null or empty. Empty or null removes the property from the Hashtable.
if(value == null | value == String.Empty )
{
this._properties.Remove(name);
}
else
{
if(this._properties.ContainsKey(name))
{
// Change if key exists
this._properties[name] = value;
}
else
{
// Add if key does not exist
this._properties.Add(name, value);
}
}
// Build a new url string
this.BuildUrlString();
}
// Catch and handle a more specific exception in a propduction application.
catch(Exception ex)
{
// Sample throws the exception to the client
throw ex;
}
}

/// <summary>
/// Enumerate Hashtable and create report server access specific string.
/// </summary>
/// <param name="properties"></param>
/// <returns></returns>
private string EmumProperties(Hashtable properties)
{
string paramsString = String.Empty;
// Enumerate properties and create report server specific string.
IDictionaryEnumerator customPropEnumerator = properties.GetEnumerator();
while ( customPropEnumerator.MoveNext() )
{
paramsString += "&"
+ customPropEnumerator.Key
+ "=" + customPropEnumerator.Value;
}

return paramsString;
}

/// <summary>
/// 接受Axps传递的参数
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
public void SetQueryParameter(string name, string value)
{
this.SetParameter(name , value);
}

/// <summary>
/// Add URL access command for rendering a report and any
/// additional parameters.
/// </summary>
public string BuildUrlString()
{
this._url = this._serverUrl + "?" + this._reportPath +
"&rs:Command=Render" + this.EmumProperties(this._properties);
return this._url;
}
#endregion

}
}
vzxq 2004-11-24
  • 打赏
  • 举报
回复
help up
ToSchool 2004-11-24
  • 打赏
  • 举报
回复
各位支持一下呀,很是郁闷,没人解决。
ToSchool 2004-11-24
  • 打赏
  • 举报
回复
to : lutao206(海口冰玲)

public void SetQueryParameter(string name, string value)
{
this.SetParameter(name , value);
}

这句话不能通过的,说“窗体不包含对SetParameter的定义”。我把它直接写在.cs文件中。
lijianlee 2004-11-24
  • 打赏
  • 举报
回复
关注中,帮你顶顶。
ToSchool 2004-11-24
  • 打赏
  • 举报
回复
很是郁闷,没人解决。
lutao206 2004-11-23
  • 打赏
  • 举报
回复
/// <summary>
/// 接受Axps传递的参数
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
public void SetQueryParameter(string name, string value)
{
this.SetParameter(name , value);
}

//*********************************
添加后,重新生成,引用。。。。。。。。。。。。。。。。。
ReportViewer1.SetQueryParameter("Parameter1", 1);

ReportViewer1.SetQueryParameter("Parameter2", 2);

所传递参数不限...................


lutao206 2004-11-23
  • 打赏
  • 举报
回复
// ReportViewer1.ServerUrl = "http://sps.hnpc.com.cn/ReportServer";
ReportViewer1.ReportPath = "/Sxfy/ReportFillCollect" ;

ReportViewer1.SetQueryParameter("Year", this.DropDownList4.SelectedValue);

//*********************************************
添加服务控件一个方法......然后在cs中调用就行了.....
ToSchool 2004-11-22
  • 打赏
  • 举报
回复
请问第一种是用URL带参数直接访问,请楼上高手能不能给个实例或说详细点,Reporting Server入门不久,不是很明白的,请高手耐心指教,表示感谢了。已经转了好几次帖了,就是没人回答。
SeeSunSet 2004-11-22
  • 打赏
  • 举报
回复
二种访问方式,一种是用URL带参数直接访问.一种是用WEBSERVICES访问..
建议你听一听在线讲座..
http://www.mswebcast.com.cn/technet/recordItem.aspx?id=msft082604vx
adminyao 2004-11-22
  • 打赏
  • 举报
回复
friendliess up + study

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧