【发布时间】:2016-03-23 18:55:50
【问题描述】:
我想将用户表单中的 sql 参数传递给我的报表类,但它不工作,也没有创建报表,当我在报表类中添加 ID 参数后再次打开报表设计器选项卡时,它会刷新报表并删除我的组件。
有什么问题?
这是我的报告类:
public SodoorZemanatName(long ID)
{
InitializeComponent(ID);
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Designer generated code
private void InitializeComponent(long ID)
{
this.components = new System.ComponentModel.Container();
DevExpress.DataAccess.Sql.CustomSqlQuery customSqlQuery1 = new DevExpress.DataAccess.Sql.CustomSqlQuery();
DevExpress.DataAccess.Sql.QueryParameter queryParameter1 = new DevExpress.DataAccess.Sql.QueryParameter();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SodoorZemanatName));
this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand();
this.detailBand1 = new DevExpress.XtraReports.UI.DetailBand();
this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();
this.sqlDataSource2 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.topMarginBand1.HeightF = 100F;
this.topMarginBand1.Name = "topMarginBand1";
this.detailBand1.HeightF = 100F;
this.detailBand1.Name = "detailBand1";
this.bottomMarginBand1.HeightF = 100F;
this.bottomMarginBand1.Name = "bottomMarginBand1";
this.sqlDataSource2.ConnectionName = "Context";
this.sqlDataSource2.Name = "sqlDataSource2";
customSqlQuery1.Name = "Query";
queryParameter1.Name = "ID";
queryParameter1.Type = typeof(long);
queryParameter1.ValueInfo = "0";
queryParameter1.Value = ID;
customSqlQuery1.Parameters.Add(queryParameter1);
customSqlQuery1.Sql = "select * from LG_Garanti where ID=@ID";
this.sqlDataSource2.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {
customSqlQuery1});
this.sqlDataSource2.ResultSchemaSerializable = resources.GetString("sqlDataSource2.ResultSchemaSerializable");
this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
this.topMarginBand1,
this.detailBand1,
this.bottomMarginBand1});
this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] {
this.sqlDataSource2});
this.DataSource = this.sqlDataSource2;
this.Version = "15.2";
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
}
#endregion
这是我的使命:
SodoorZemanatName report = new SodoorZemanatName(1);
ASPxDocumentViewer1.ReportTypeName = "SodoorZemanatName";
ASPxDocumentViewer1.Report = report;
【问题讨论】:
-
我认为你需要单独设计报表。简单地使用
new DevExpress.XtraReports.UI.XtraReport();可能不行,因为它不知道如何使用你的数据源,如何显示数据。DevExpress.XtraReports.UI.XtraReport report = new your_report_design_class();我以前用过这种东西,我必须先用我的设计创建新的报告,然后再为其分配数据源
标签: c# webforms devexpress report