3

ユーザーが番号を入力してテーブルから情報を取得するテキストボックスがあるWebフォームがあります。これで、エクストラレポートを作成しました。ここでは、前述のテキストボックスにユーザーが入力したデータを表示する必要があります。すべてが正常に機能します。texbox(form1)の値をレポート(form2)に渡すだけで済みます。

ここで必要なのは、テキストボックスの値をパラメーターとしてレポートに渡し、選択した番号のレポートデータを表示する方法です。

4

2 に答える 2

0
  1. レポートデザイナでレポートパラメータを作成し、レポートの任意の場所(レポートフィルタなど)で使用する必要があります。
  2. レポートをユーザーに表示する前に、レポートインスタンスでパラメーターを見つけて、それに値を割り当てる必要があります。

サンプルコードは次のとおりです。

                        using (var report = new XtraReport())
                        {
                            report.Bands.Add(new DetailBand());
                            report.Parameters.Add(new Parameter { Name = "userName",ParameterType = ParameterType.String});
                            report.FilterString = "USER = userName";
                            report.SaveLayout("test.repx");
                        }
                        using (var report = new XtraReport())
                        {
                            report.LoadLayout("test.repx");
                            report.Parameters.First(p => p.Name == "userName").Value = textBox.Text;
                            report.ShowPreviewDialog();
                        }

注意
これはwinformサンプルです。しかし、原則は同じです。また、たとえばクエリ文字列を介してテキストボックスの値をWebフォームに渡すのは非常に簡単です。

于 2010-03-14T07:02:04.333 に答える
0

そのテキストエディット値を取得し、コンストラクターを渡します。

 string oper = "A";
 XtraReport_1 report = new XtraReport_1(oper, Convert.ToInt32(TextEdit1.Text));

 ReportPrintTool tool = new ReportPrintTool(report);
 tool.ShowPreview();

wherefiresが報告する場合に備えてこのコードを記述してください。

そのXtraReport_1コンストラクターを取得して使用します。

public InvoiceReport_1(string oper, int p)
    {
        // TODO: Complete member initialization
        InitializeComponent();
        InvisibleText.Text = p.ToString();
        InvisibleText.Visible = false;

        getOper = oper;

    }

これで、「InvisibleText」と呼ばれるテキストエディットの値を取得できます。

于 2013-12-27T11:54:16.607 に答える