|
板凳
楼主 |
发表于 2012-4-6 11:02:18
|
只看该作者
本帖最后由 redleaf 于 2012-4-6 11:10 编辑
官网示例没有这样的问题。
问题是这样的:在页面上加入Fastreport.net报表后,如用报表中的保存功能时,会出现这样的问题。(可能保存按钮是客户端控件)。
在很早前的版本中是不报错的,但是如第一次在没有查询数据时,点保存后extropDownList中的值会被清空。
//.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="artUsedChartReport.aspx.cs" Inherits="WebTeam.Reports.PartUsedChartReport" %>
<%@ Register Assembly="FastReport.Web" Namespace="FastReport.Web" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>子报表</title>
<script src="../../res/js/Report.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<extageManager ID="ageManager1" AutoSizePanelID="RegionPanel1" runat="server"
EnableAjax="false" />
<ext:HiddenField runat="server" ID="hidPreValue">
</ext:HiddenField>
<ext:RegionPanel ID="RegionPanel1" runat="server">
<Toolbars>
<ext:Toolbar ID="Toolbar2" Position="Top" runat="server">
<Items>
<ext:ToolbarFill ID="ToolbarFill2" runat="server">
</ext:ToolbarFill>
</Items>
</ext:Toolbar>
</Toolbars>
<Regions>
<ext:Region Position="Top" Height="60px" ShowHeader="false" ShowBorder="false">
<Items>
<ext:Form ID="Form2" runat="server" LabelWidth="40px" ShowHeader="false" ShowBorder="false">
<Rows>
<ext:FormRow>
<Items>
<extabel runat="server" ID="lblExplain" CssStyle="font-size:16;font-weight:bold;">
</extabel>
</Items>
</ext:FormRow>
<ext:FormRow>
<Items>
<extropDownList ID="ddlYear" Label="年份" Width="160px" runat="server" AutoPostBack="false">
</extropDownList>
<extropDownList ID="ddlPartType" Label="分类" Width="160px" runat="server" AutoPostBack="false">
</extropDownList>
<ext:Button runat="server" Text="查询" ID="btnReport1">
</ext:Button>
</Items>
</ext:FormRow>
</Rows>
</ext:Form>
</Items>
</ext:Region>
<ext:Region Position="Center" ShowHeader="false" ShowBorder="false" Layout="Fit">
<Items>
<ext:ContentPanel runat="server" ShowHeader="false" ShowBorder="false">
<cc1:WebReport ID="WebReport1" runat="server" PrintInPdf ="true"
ShowToolbar="true" Zoom="1" Height="481px" Padding="5, 5, 5, 5" Width="810px" />
</ext:ContentPanel>
</Items>
</ext:Region>
</Regions>
</ext:RegionPanel>
</form>
</body>
</html>
//.cs
using System;
using System.Web;
using System.Xml;
using System.ComponentModel;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using FastReport.Data;
using FastReport;
using FastReport.Web;
using System.Windows.Forms;
namespace WebTeam.Reports
{
public partial class PartUsedChartReport : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
WebReport1.Prepare();
BindDDL();
}
}
protected void btnReport1_Click(object sender, EventArgs e)
{
hidPreValue.Text = "query";
WebReport1.Prepare();
}
protected void WebReport1_StartReport(object sender, EventArgs e)
{
if (hidPreValue.Text == "")
{
return;
}
hidPreValue.Text = "";
Report FReport = WebReport1.Report;
RegisterData(FReport);
}
private void RegisterData(Report fReport)
{
this.Title = base.GetQueryValue("ReportTitle");
FastReport.EnvironmentSettings fsetting = new FastReport.EnvironmentSettings();
fsetting.PreviewSettings.Buttons = FastReport.PreviewButtons.All | FastReport.PreviewButtons.Close;
fsetting.UIStyle = FastReport.Utils.UIStyle.Office2007Blue;
//选择模板
string sPath = CAXA.WEB.Utility.SysConfig.GetWebAppRootDir();
string sFileName = sPath + "\\Reports\\PartUsedChart.frx";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(sFileName);
fReport.Report.LoadFromString(xmlDoc.InnerXml);
//设置报表中的参数值
string sTitle1 = ddlPartType.SelectedText.ToString();
fReport.Report.SetParameterValue("_type", sTitle1);
string sTitle2 = ddlYear.SelectedValue.ToString();
fReport.Report.SetParameterValue("_year", sTitle2);
System.Data.DataSet ds = new System.Data.DataSet();
//注册数据
fReport.Report.RegisterData(ds);
fReport.Report.FileName = this.Title;
}
private void BindDDL()
{
base.BindDDLPartTypes(ddlPartType);
base.BindDDLYear(ddlYear, false);
}
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|