Stimulsoft_Report纯代码实现数据绑定

4 篇文章 0 订阅

根据穿的参数动态绑定显示报表,涉及多表查询。

一、前台代码:

  <%@ Page Title="" Language="C#" MasterPageFile="~/WebMaster/OpenWin_FixHead.Master" AutoEventWireup="true" CodeBehind="ProjectReport.aspx.cs" Inherits="HuaiNanSys.Page.ProjectInformation.ProjectReport" %>
<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc1"   Assembly="Stimulsoft.Report.Web"%>
<%@ register Namespace="Stimulsoft.Report.Web" TagPrefix="cc2" Assembly="Stimulsoft.Report.WebDesign"%>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
     <cc1:StiWebViewer ID="StiWebViewer1" runat="server" GlobalizationFile="/Content/page/reports/Localization/zh-CHS.xml" ShowDesignButton="False" onreportdesign="StiWebViewer1_ReportDesign" Theme="Office2010" BackColor="#e8e8e8"/>
     <cc2:StiWebDesigner ID="StiWebDesigner1" runat="server" LocalizationDirectory="/Content/page/reports/Localization/" Localization="zh-CHS"  onsavereport="StiWebDesigner1_SaveReport" />

</asp:Content>

二、后台代码:

using Stimulsoft.Report;
using Stimulsoft.Report.Components;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Page.ProjectInformation
{
public partial class ProjectReport : BaseContentPage_UsingMaster
{
protected void Page_Load(object sender, EventArgs e)
{
string RowGuid = Request.QueryString[“RowGuid”];

        ShowReport(RowGuid);
    }
    public void ShowReport(string rowGuid)
    {
        DataSet ds = new DataSet();
        MisGuidRow mis = new MisGuidRow("View_ProjectInformation");
        DataView dv = mis.Select("*", "RowGuid='" + rowGuid + "'");
        ds.Tables.Add(dv.ToTable());
        string filepath = Server.MapPath("~/Report.mrt");
        StiReport stireport = new StiReport();
        stireport.Load(filepath);

        stireport.RegData("datasource", ds);

        DataTable dt = ds.Tables[0];
        StiDataBand D = stireport.Pages[0].Components["DataBand1"] as StiDataBand;
        StiText ProjectName = D.Components["ProjectName"] as StiText;
        ProjectName.Text = Convert.ToString(dt.Rows[0]["ProjectName"]);



        stireport.Compile();
        StiWebViewer1.Report = stireport;

    }


    protected void StiWebViewer1_ReportDesign(object sender, Stimulsoft.Report.Web.StiReportDesignEventArgs e)
    {
        string filepath = Server.MapPath("~/Report.mrt");
        StiReport stireport = new StiReport();
        stireport.Load(filepath);
        stireport.Compile();
        StiWebDesigner1.Design(stireport);
    }

    protected void StiWebDesigner1_SaveReport(object sender, Stimulsoft.Report.Web.StiWebDesigner.StiSaveReportEventArgs e)
    {
        var report = e.Report;
        string filepath = Server.MapPath("~/Report.mrt");
        report.Save(filepath);
    }
}

}

三、引用dll
这里写图片描述

四、在designer.exe中设计报表,只需要画出样式,不需要连接和绑定数据源
报表树结构如下:用的是text
这里写图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值