我有两个主子报表ReportMain,ReportDetail,现在我通过ReportView控件来显示。当显示ReportMain的时候没有问题,可是当我一点ReportMain中的ID列,想跳到它所对应的ReportDetail上去,可此时就不是在ReportView控件中显示了,而是显示到http://localhost/ReportServer上了,请问这样的问题该如何解决。
(注:ReportView控件是在一个框架页上的)。
(注:ReportView控件是在一个框架页上的)。
是加到那里呢???
wbj02(J^情之弦^J) 请问一下你的参数是如何传得呢?
给你一些思路吧!
你可以在控件里面,或者说你可以直接写成公用的CLASS都可以,reportingServices提供了一个Render的方法,用来得到报表的内容,返回值为byte[]数组,然后你可以用System.Text.Encoding.UTF8.GetString( 得到的byte[]数组 )方法转换为HTML格式的string,然后把里面对应的http://localhost/ReportServer/ReportService.asmx替换为你自己的web地址就可以了。
protected override void Render(HtmlTextWriter output){}
我怎么可以得到HTML格式的string
{
StringWriter writer1 = new StringWriter();
HtmlTextWriter writer2 = new HtmlTextWriter(writer1);
base.Render(writer2);
string text1 = writer1.ToString().Trim(); //此处可以修改呈现内容。 output.Write(text1);}
protected override void Render(HtmlTextWriter output)
{
if (this._serverUrl == String.Empty || this._reportPath == String.Empty)
{
output.Write("<P style=\"font-family: Verdana; font-size: 12px\">");
output.Write("请在左边选择你要查看的报表。</P>");
}
else
{
// System.Text.Encoding.GetEncoding();
// Create IFrame if the user enters ServerUrl and ReportPath
Microsoft.Samples.ReportingServices.ReportingService.ReportingService rs =
new Microsoft.Samples.ReportingServices.ReportingService.ReportingService(); byte[] result = null;
string reportPath = this._reportPath;
string format = "MHTML";
string historyID = null;
string devInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"; // Prepare report parameter.
ParameterValue[] parameters = null; DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
SessionHeader sh = new SessionHeader();
rs.SessionHeaderValue = sh; try
{
result = rs.Render(reportPath, format, historyID, devInfo, parameters, credentials,
showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings,
out streamIDs); string strHtml = System.Text.Encoding.UTF8.GetString(result);
}
catch(System.Exception ex)
{
string str = ex.Message;
throw ex;
}
output.WriteBeginTag("iframe");
output.WriteAttribute("src", this.BuildUrlString());
output.WriteAttribute("width", this.Width.ToString());
output.WriteAttribute("height", this.Height.ToString());
output.WriteAttribute("style", "border: 1 solid #C0C0C0");
output.WriteAttribute("border", "0");
output.WriteAttribute("frameborder", "0");
output.Write(HtmlTextWriter.TagRightChar);
output.WriteEndTag("iframe");
output.WriteLine();
}
}
??,什么情况下出现的?你看看是不是你参数带错了,比方说多了特殊字符之类
参数好象没有你所说的多了特殊字符呀!
在有需要添加datasource吗?
reportPath 是完全路径吗?